I am seeing the same behavior, were you able to fix? Hereās my full investigation:
Hey, Iām having some issues with production deployment to vercel after upgrading from v7.7.4 to v8.2.0. The issue only shows up when deployed to vercel, local development behaves as expected. The issue is with auth/cookies not being set after the POST request to /api/auth (which does get a 200 response), but does not have the setCookie header. The subsequent GET request to /api/auth?method=getToken also has a 200 response but does not return the logged in user. This results in the user not being able to get passed the login/signup page. The behavior does not show up when developing locally. I have a test repository with the minimal changes needed to reproduce GitHub - jgal1/redwood-vercel .
v7.7.4:
- Local developemnt works
- Production deploy DOES NOT have auth issues
- Code lives in the v7.7.4 branch of the linked repo
- Vercel Deployment: See next comment new users canāt post more than two links on this discussionā¦
v8.0.0:
- Local developemnt works
- Production deploy DOES have auth issues descibed above
- Code lives in the v8.0.0 branch of the linked repo
- Vercel Deployment: See next comment new users canāt post more than two links on this discussionā¦
v8.2.0:
- Local developemnt works
- Production deploy DOES have auth issues descibed above
- Code lives in the main branch of the linked repo
- Vercel Deployment: See next comment new users canāt post more than two links on this discussionā¦
Please let me know if you need any more information about my setup. The app is setup with a free supabase postgres instance (example format for env vars below), hosted on vercel with env vars set in the following format:
- SESSION_SECRET= secret obtained from running āyarn rw g secretā
- DATABASE_URL=See next comment new users canāt post more than two links on this discussionā¦
- DIRECT_DATABASE_URL=See next comment new users canāt post more than two links on this discussionā¦
The codebase for the reproduction lives at GitHub - jgal1/redwood-vercel . The v7.7.4 branch has the code which works for both local and vercel deployment, the v8.0.0 branch has the v8.0.0 code which does not work when deployed to vercel, and the main branch has the v8.2.0 version which also does not work when deployed to production.
To get a fresh repository for the minimal reproduction follow the below steps:
yarn create redwood-app redwood-vercel --typescript
cd redwood-vercel && yarn install
yarn rw setup ui tailwindcss
yarn rw setup auth dbAuth
yarn rw setup deploy vercel
The vercel deployment uses the standard redwood preset, and the only requirement on vercel is to set the environmental variables which are stated above.
This shouldnāt make any difference for this issue but for my specific case, to connect to the supabase postgres instance the schema.prisma file needs the following edit to the ādatasourceā config:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL")
}
For local development, the DATABASE_URL and DIRECT_DATABASE_URL should be the same and point to a local postgres instance
Please let me know if there is anything I can do to help debug, for example any vercel permissions issues viewing the deployed domains, or vercel logs.