I am currently following a ReactJS Tutorial and am having trouble setting up a database to store some information. I am using firebase for the database and when I use the fetch();
function in javascript I get the first error:
from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
and then the error
Failed to load resource: the server responded
( url) with a status of 400 (Bad Request)
. I considered the fact that the issue may be the connection from my network to the database but it would not explain the first error I received. I appreciate any responses. Thank you!
CodePudding user response:
your answer to the question is on this link
edit your app.js file.
app.get('/cors', (req, res) => {
res.set('Access-Control-Allow-Origin', '*');
res.send({ "msg": "This has CORS enabled