更新时间:2023-02-25 22:37:48
您是否尝试过Express / Cors我最近在访问允许来源方面也遇到了问题,然后我从
have you ever tried express/cors i recently also had problem with access allow origin then i download express/cors from
npm install cors
然后在程序中添加
var express = require('express')
var cors = require('cors')
var app = express()
app.use(cors())
app.get('/products/:id', function (req, res, next) {
res.json({msg: 'This is CORS-enabled for all origins!'})
})
app.listen(80, function () {
console.log('CORS-enabled web server listening on port 80')
})
您还可以在[link] https:// github中看到其他使用cors的方法.com / expressjs / cors
you can also see other method to use cors in [link]https://github.com/expressjs/cors