Вы можете установить некоторые конфиги на вашем express.js
сервере.
app.use(function(req, res, next) {
var allowedOrigins = [
'http://localhost',
'http://localhost:8000',
'http://127.0.0.1',
'http://127.0.0.1:8000',
'http://yourdomain.com',
];
var origin = req.headers.origin;
if (allowedOrigins.indexOf(origin) > -1) {
res.setHeader('Access-Control-Allow-Origin', origin);
}
res.header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE, OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
res.header('Access-Control-Allow-Credentials', true);
next();
});