const cors = require('cors');
const app = express();
app.use(cors());
const app = express();
app.use((req, res, next) => {
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, Authorization');
next();
});
const express = require('express');
const cors = require('cors');
const app = express();
app.use(cors());
// ...
'Access-Control-Allow-Origin': '*' // * или ваш домен
'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE'
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept'
axios.get('https://cors-anywhere.herokuapp.com/https://some-cors-not-allowed-api.com');
127.0.0.1 my-app
server {
listen 80;
server_name my-app;
location ^~ / {
proxy_pass http://localhost:81/;
}
location ^~ /api/ {
proxy_pass http://localhost:5000/api/;
}
}
http://my-app
и к API в приложении как к http://my-app/api
.