Home > Back-end >  CORS policy: No 'Access-Control-Allow-Origin'
CORS policy: No 'Access-Control-Allow-Origin'

Time:05-09

Im develop a react website with node js backend than react show some error link enter image description here

CodePudding user response:

That's to do with the backend. Your server isn't set up to receive requests from the URL you're using (localhost). If you're the one writting the server, look up the cors npm package to enable cross site requests. Otherwise, ask whoever is the author of the server.

CodePudding user response:

you are not useing cors or same url for frondend and backend thats why this error coming .For send data frontend to sarver you need use "cors" package. install cors:

        npm install cors

then requre it index.js file

        const cors = require('cors')
         app.use(cors())
  • Related