dubinc/dub

Getting constantly re-routed to /login

rfrlcode opened this issue · 9 comments

Hi, I made a deployment on vercel to play around, and after login (using github) I get re-routed to the login page. Not sure whats up. Has anyone dealt with this?

Thanks

I also got this error during the vercel build:
web:build: withSession Error --> Dynamic server usage: Route /api/me couldn't be rendered statically because it accessed request.headers. See more info here: https://nextjs.org/docs/messages/dynamic-server-error

but for some reason it all still compiled

@devkiran would you have a few moments to help with this? I redeployed using the latest commit: https://github.com/dubinc/dub/tree/c3b506ba5317e0b0b56116c83604cb5339d4cea8, and still facing the same issue.

Just tried the latest build again. Same issues. Even tried on a pro vercel plan. Still getting re-routed to login. Tried google login, and faced the same issue.
Dont face the same issue in local development. Super weird. It correctly routes to the /welcome flow after logging in with github locally.

I then tried to deploy another NextJs project (that uses AuthJs) on vercel to identify if the issue is specific to the dub repo. Did not face any login issues in this other project. @steven-tey, would you be able to provide some guidance on what I can try next.

@rfrlcode Can you see any errors in the console in the local dev env?

During local development, there are no errors during login.
The login works as expected, and I am put through the welcome flow. I can make workspace, delete it, delete account etc.
There is one error that happens when I try to create a link which you can see in this video:

Screen.Recording.2024-03-20.at.9.18.46.AM.mov

Here is a screenshot of the error:
Screenshot 2024-03-20 at 9 20 07 AM

However, the login routes as expected.

@devkiran, let me know if I can provide something else. Thanks.

I added a console log to middleware to see if there is a session after login:
const session = (await getToken({
req,
secret: process.env.NEXTAUTH_SECRET,
})) as {
email?: string;
user?: UserProps;
};
console.log("session", session);

in local dev there seems to be a valid session after login, but session is null after login in vercel. that seems to be the issue.

lol, finally figured it out.
the next auth url needs to be https://app.acme.com, and not http://app.acme.com