Currently I have an existing Node.js backend that works with my create-react-app project.
I'm migrating to NextJS but have some questions.
I have a simple JWT authentication process:
- frontend makes request to
my-server/api/auth - backend authenticates user, adds refresh token as
httpOnlycookie to response header. and returns access token as response body. - Every next call to server will include the access token and refresh token in cookies.
My quesetion is if my NextJS app which is deployed to vercel with domain: www.my-nextjs-app.vercel.com, is making requests to my backend app which is deployed to aws at www.my-backend-app.aws.com, then the cookies my backend set won't be applied because of CORS (since they considered third party cookies from different domain).
(That's also true if I locally server my create-react-app at localhost:3000 and make requests to my local server at localhost:5000, chrome won't show the httpOnly cookie because it's from a different domain)
This is different from my create-react-app which was served directly from my backend at the same domain and thus had no problem of third party cookies.
Is there a solution for that?
Edit: Also, is Next.JS really meant to be used with an existing server? or serverless only
