Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Access to XMLHttpRequest has been blocked by CORS policy node js

/*
npm i cors
or
 yarn add cors
then in your node app
*/
const cors = require('cors');
const corsOptions ={
    origin:'http://localhost:3000', 
    credentials:true,            //access-control-allow-credentials:true
    optionSuccessStatus:200
}
app.use(cors(corsOptions));
 
PREVIOUS NEXT
Tagged: #Access #XMLHttpRequest #blocked #CORS #policy #node #js
ADD COMMENT
Topic
Name
1+2 =