NextJS Express Server Cookies

I'm facing an issue with Cookies in Next.js due to separate domains for my Express backend and Next.js. The JWT cookies set in Express aren't accessible in Next.js SSR because they have the Express Domain. Considering routing API calls through Next.js's API routes before reaching the Express server to resolve the issue. Any thoughts or alternative solutions for seamless integration? (Next.js is deployed on Vercel and Express Server on AWS)
No description
4 Replies
imEddieđź‘»
imEddie👻•6mo ago
If you need any extra details please lmk
Starko00
Starko00•6mo ago
I did this in 2 ways the first one (everything client side), the second way in API folder u can build a small apstraction on top of it so that all the requests that go to your server pass thro your api layer meaning only your server keeps the jwt token (but u can pass it to your client as well )
imEddieđź‘»
imEddie👻•6mo ago
If I do the second way the aws server and the next.js server would both need the jwt token. even if i crete the token in the next server my aws server would still need it. Also why does the client have access to the cookie set from the aws server in the first place? 🤔
Starko00
Starko00•6mo ago
Well it only forwards the token meaning your next js backend is actualy making requests and not your client for example you want to get on client your client will ask your api route and the api route wil auth to your server
Want results from more Discord servers?
Add your server
More Posts