Can't use auth in layouts/pages in Safari
Answered
Sphecid wasp posted this in #help-forum
Sphecid waspOP
For some reason, it looks like one of my layouts is rendering twice as if it's a client component but the first time it's returning null and causing a redirect. The server action appears to be working correctly because it redirects to the correct route but the code being called in that route is causing a second redirect when the value of validateRequest returns null the first time the page is generated. For some reason everything works fine in Chrome-based browsers but not in Safari. What could be happening? Why is the page getting generated twice when I make a request with Safari?
Answered by Sphecid wasp
An update on this. It appears to just be coming back null/null. Not sure if I was logging it somewhere else. Works fine in Chrome-based browsers.
6 Replies
Sphecid waspOP
An update on this. It appears to just be coming back null/null. Not sure if I was logging it somewhere else. Works fine in Chrome-based browsers.
Answer
Sphecid waspOP
A further update. Safari doesn't appear to be setting the cookie when the server action is successful.
I needed to add --experimental-https to the npm run dev script so that Safari honors the
secure flag.@Sphecid wasp A further update. Safari doesn't appear to be setting the cookie when the server action is successful.
localhost is not secure, but other browsers still allow secure cookies as an exception. Safari doesn’t do that.
experimental-https is a way, though I prefer simply using secure: process.env.NODE_ENV === "production"
experimental-https is a way, though I prefer simply using secure: process.env.NODE_ENV === "production"
Sphecid waspOP
Thanks for the tip. Any reason to do that over the https setting?
https is experimental as the name suggests. I’ve seen many bug reports related to it. I would prefer avoiding experimental things if I can use alternatives.