Redirect and set cookie from server function called in loader
I have a page that validates a token from an email link and then sets a cookie and redirects to a page the user now has access to. You can imagine this would work similar to an "magic link" email based auth system.
When I try to set the cookie and redirect from the server function called by the route's
loader, the cookie seems to never be set.In my route I have the loader setup to call the server function:
The redirect is working correctly, however, no cookie is being set. I have tried a few combinations with setting headers as explicitly like so:
Or as part of the redirect but neither seem to be working since the
getSetCookie() returns an empty array while being called after setCookie():I have also tried calling the server function from the route's
beforeLoad but that did not work either.Would love to know if I'm missing something or if this is not supposed to work, any workarounds you'd suggest. Thanks in advanced.