-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
First, great job by the Svelte community, I have been using it for all my projects right from the day, I learned about it.
But I have been dealing with this problem, even in my previous project, I had to rewrite my auth logic at the last moment right before launching.
I don't want to do that with my current project because my previous project was just a single dashboard page, so I could just move the logic to the shadow endpoint of my page.
But this project contains many pages like Setting, Profile, and more.
In my login endpoint, I create and save a new cookie to the user browser, so I can use that to evaluate when they reload or try to visit some routes, in this case when they visit the login page, I check if there is a cookie named access_token and then redirect them to their dashboard, else, proceed with the user request, same logic if they visit the dashboard and the is no access_token
The issue is that everything is working as it should in development, but when I build and upload to netlify it starts acting weird, if you visit the dashboard when there's a cookie, the whole page is stuck. What is think is happing, is that somehow, the hook is not recognizing that there's a cookie, but when it redirects to the login, it recognizes there's a cookie and redirects to the dashboard, and the loop continues.
How to reproduce Error
git clone https://github.com/jsaretin/svelte-hook-auth-error
cd svelte-auth-error
npm install
npm run build
npm run preview
then login and visit the user dashboard
Reproduction
Logs
No response
System Info
System:
OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
Memory: 2.05 GB / 7.46 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 16.15.0 - /usr/local/bin/node
npm: 8.5.5 - /usr/local/bin/npm
Browsers:
Brave Browser: 103.1.41.100
Chrome: 103.0.5060.134
Firefox: 102.0
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.63
@sveltejs/kit: next => 1.0.0-next.392
svelte: ^3.44.0 => 3.49.0
vite: ^3.0.0 => 3.0.2Severity
annoyance
Additional Information
No response