Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Access to XMLHttpRequest has been blocked by CORS policy

/*
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));
Comment

access-to-xmlhttprequest-has-been-blocked-by-cors-policy

app.use(function (req, res, next) {
    //Enabling CORS
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, 
    Accept, x-client-key, x-client-token, x-client-secret, Authorization");
      next();
    });
Comment

access-to-xmlhttprequest-has-been-blocked-by-cors-policy

app.use(function (request, response, next) {
  response.header("Access-Control-Allow-Origin", "*");
  response.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  next();
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: convert date to timestamp javascript 
Javascript :: js foreach 
Javascript :: how to add data to file json in python 
Javascript :: reduce array to object javascript 
Javascript :: union of two arrays javascript 
Javascript :: chalk nodeks 
Javascript :: javascript console.log alternative 
Javascript :: javascript replace all spaces 
Javascript :: element en html and js 
Javascript :: showing bootstrap modal after a delay 
Javascript :: react hook form with yup resolver 
Javascript :: adding to array using reach hooks 
Javascript :: how to select div js 
Javascript :: regex to check if text is in quotations 
Javascript :: js  
Javascript :: react-data-table-component api action button 
Javascript :: fetch method in js 
Javascript :: formula for scrollbar size 
Javascript :: lorem ipsum json api 
Javascript :: open bootstrap modal with javascript 
Javascript :: smooth-scroll.js 
Javascript :: getting average of array javascript 
Javascript :: how to autoload config files added in composer.json laravel 
Javascript :: onclick function jquery 
Javascript :: reload react native app 
Javascript :: jquery datatable checkbox checked row data 
Javascript :: Javascript random password generator Exampe 
Javascript :: jquery focus input end of text 
Javascript :: dataset js 
Javascript :: how to get number of a specific element of an array 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =