1

from origin 'http://localhost:3003' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

when i post request using the other domain serves how i solve the problem!!

gemma
  • 61
  • 1
  • 1
  • 9

4 Answers4

1

For development you can use proxy to localhost:3003. Write this line in package.json of react project. "proxy": "http://localhost:3003".

To solve this issue, you will have to do in backend, for example if you backend is in nodejs then you can use CORS package.

Install cors package.

npm i cors

and then in your nodejs file write this

var cors = require('cors');
app.use(cors())

To configure cors you can refer documentation

Shikhar Awasthi
  • 1,172
  • 1
  • 3
  • 13
1

There is this post still on stackoverflow i believe it will help

How to allow CORS in react.js?

MUGABA
  • 751
  • 6
  • 7
-1

I installed the cors unblock extension in Google Chrome and no more problems to me.

  • i want to upload my project website who to solve this issue!! – gemma May 26 '22 at 10:41
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 27 '22 at 07:53
-1

in your node.js backend add:

app.use(cors({origin: true, credentials: true}));

also you can try installing this chrome extension. it fixed the issue for me

Dzalev
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 27 '22 at 08:01