Search code examples
next.jsvercelclerk

Clerk redirecting to localhost after authentication


On my production site hosted on vercel, after authentication with clerk, it redirects me to localhost. This only happens on the laptop I'm using for development.

If I connect to the production site on another device, it correctly redirects me back to the production site hosted on vercel after authentication.

I'm following a tutorial for the t3 stack here:https://www.youtube.com/watch?v=YkOSUVzOAA4

I'm new to this stack and using nextJS + vercel + clerk so I'm not sure where to even begin. I'll upload any needed code. Thank you.


Solution

  • Follow Clerk's Next.js setup instructions and it should help get it working. Specifically adding a sign-in and sign-up page and creating these environment variables:

    NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
    NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
    NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
    NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/
    

    That should get things working on the Vercel deploy without the weird redirection issue.

    https://clerk.com/docs/nextjs/get-started-with-nextjs