I have a custom auth solution that is designed to work like this:
- User adds email
- Email is sent to the user with link (with a token)
- User clicks link, which hits an auth endpoint. If the token is valid, a cookie is set and they are redirected to the home page, signed in.
When I mimic the email behavior by printing a link on the screen, everything works fine.
But when I mimc an email service (using Nodemailer + Ethereal in the test), I run into a consistent issue. Flow is like this:
- User lands on the auth page as expected.
- Auth page does what it should and sets the cookie. I can log the cookie to the console from the auth page.
- Redirects, as expected to the home page.
- Home page can't get the cookie (which is set).
- Refreshing doesn't help, including a hard refresh
- What ultimately solves it is clicking another link in the UI.
This is all happening locally and with SSR. I haven't tried deploying it yet.