我正在使用Cors()模块,并相信我在服务器项目上正确使用它:
...
var corsOptions = {
origin: 'http://localhost:8000'
};
...
app.use(cors());
...
app.post('/auth/instagram', cors(corsOptions), function(req, res) {
var accessTokenUrl = 'https://api.instagram.com/oauth/access_token';
.....
然而,当终端被客户端击中时,我仍然在控制台中收到以下消息:(注:服务器端在3000端口,客户端在8000端口)
XMLHttpRequest cannot load http://localhost:3000/auth/instagram. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:8000' is therefore not allowed access.
必须指定以下内容:
app.use(cors({credentials: true, origin: true}));