get cors policy code example
Example 1: javascript cors error
$.ajax({
headers: { "Accept": "application/json"},
type: 'GET',
url: 'http://cl.ly/2wr4',
crossDomain: true,
beforeSend: function(xhr){
xhr.withCredentials = true;
},
success: function(data, textStatus, request){
console.log(data);
}
});
Example 2: how to use cros
npm i cors
const cors = require('cors');
const express = require('express');
const app = express();
app.us(cors());