xxxxxxxxxx
/*
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));
xxxxxxxxxx
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();
});
xxxxxxxxxx
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();
});
xxxxxxxxxx
host password org bri
xxxxxxxxxx
The problem occur when i click to retrieve the data from database
in laravel i am using msqli database please help me in this problem
$(function(){
$(document).rea
url = window.location.origin+"/todo/index";
console.log(url);
$.ajax({
url : url,
type: 'get',
success: function (response) {
console.log(response);
}
});
});