deploying a Node/React project in Vercel

16 views Asked by At

I wanna deploy a full stack project in Vercel. It consist of a Front end in one file, with react and vite and a Backend in another file with Node and Express. Both are in the same Git repo (https://github.com/xsolarxx). It's an end of bootcamp project.

I tried a few things already but nothing worked so far. I created a Vercel account with the same credentials of the git account and deployed. But I had CORS issues.

My understanding is that I have to update first the index file in the backend, because at the moment is deploying to the PORT. Not really sure what I have to do in the backend actually. Then I have to update the "baseURL" in the serviceApiGeneral.config file in the front end with the URL that vercel provided.

Any other steps I am unaware of? I followed this article from vercel https://vercel.com/guides/how-to-enable-cors but I was then told that it was not needed.

I added an "allowCors" function based on this https://vercel.com/guides/how-to-enable-cors

I creaded a NODE/vercel.json

"headers": [
   { "key": "Access-Control-Allow-Credentials", "value": "true" },
   { "key": "Access-Control-Allow-Origin", "value": "*" },
   { "key": "Access-Control-Allow-Origin", "value": "https://frontend-iota-three-81.vercel.app" },
   { "key": "Access-Control-Allow-Methods", "value": "GET,OPTIONS,PATCH,DELETE,POST,PUT" },
   { "key": "Access-Control-Allow-Headers", "value": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" }
]

I added this base URL in the front end baseURL: 'https://frontend-iota-three-81.vercel.app',

Now I undid all the changes because it was not working.

0

There are 0 answers