-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Svelte hook keeps redirecting #5687
Comments
you hit this: https://twitter.com/mlocik97/status/1528105175449231363 it's related to prerendering, but it's not actually issue in Kit... |
Thanks, for the reply, I didn't know where to post it, I have checked the referenced tweet, and I tried setting the |
if you do redirect before |
I can workaround this by skipping auth logic on build process. Here's example. Idk if this is correct, but it's work. |
Older versions of SvelteKit prerendered redirects even if the page itself wasn't marked as prerenderable. This is now fixed, so I'll close this issue. |
When using with AuthJs , it still causes problem nextauthjs/next-auth#6186 import { building } from '$app/environment';
if (building) return resolve(event); |
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 noaccess_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
then login and visit the user dashboard
Reproduction
I uploaded a sample here
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: