-
Notifications
You must be signed in to change notification settings - Fork 5
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
Could not show flash message when redirecting. #38
Comments
The tests I've made are working fine for load function redirects. Take a look at this repo and see if you can reproduce the problem: https://www.sveltelab.dev/l185ux6qusai52s |
Hi, everyone; @Sourabhpatel1, are you modifying/setting cookies elsewhere in your project? Something I did in the past was overriding the flash message cookies (unintentionally) and it frustrated me how much of an oversight it was on my end. Try sharing a repro, perhaps snippets of your |
Yes I am using lucia-auth to set session cookies. |
My
|
Classic, you need cookies.append instead: https://github.com/ciscoheat/sveltekit-flash-message?tab=readme-ov-file#when-setting-cookies-in-a-response |
We should put this in a hall of fame @ciscoheat 😂 But, yes, @Sourabhpatel1; that was my guess. You are overwriting your cookies on each navigation and clearing your flash messages in the process. |
Update: My bad @Sourabhpatel1 🙁 Just had a look and yes, as @ciscoheat mentioned here I was working with the response header itself.
|
I tried append without any luck. here is the repo link https://gitlab.com/sveltekit2/tejas-ki-dukaan I have tested on firefox and chromium. |
Sorry, |
Will do asap |
I'm also experimenting the same problem |
Same here (also using Lucia auth) :( |
I need a MRE repo to investigate this further. |
Maybe my issue was unrelated. I realized that the redirect was not working because the page I was redirecting from was already under the +layout.svelte file with the flash logic. Meaning that when I would redirect to another page (also covered under this layout) it would not run the I found that moving the flash logic to a different layout.svelte or page.svelte that needs to be reloaded worked for me. Not sure if I am solving this issue properly but it worked for me! Thanks for the great library by the way :) |
I am facing what I think is a very similar issue, I have a very similar setup as far as Lucia, Superforms and Shadcn. I have not been able to make any work around work. As far as shrinking this down I think the issues is coming from from one of these other libs? My issue when I use redirect (either sveltkit or flash redirect) even when the form submit is successful (the form writes to the db) it returns a 500 fail. I can run the same test using just setFlash no redirecting and everything works just fine. |
I am checking if a user is logged in and if true then I am redirecting to the home page but the flash messages wont show
+page.server.ts
+layout.svelte
The text was updated successfully, but these errors were encountered: