node restify cors
发布于 9 个月前 作者 dingyuanwu 789 次浏览 来自 问答
const cors = require('cors');
const restify = require('restify');
const plugins = require('restify-plugins');
const routers = require('./routes/routes');

const http_server = restify.createServer();
const setup_server = (app) => {
    app.use(cors());
    app.use(plugins.bodyParser());
    app.use(plugins.queryParser());
    app.use(plugins.authorizationParser());
    app.use(plugins.acceptParser(acceptable));

    routers.applyRoutes(app); 
};

setup_server(http_server);
http_server.listen(8083, () => {
    console.log('%s listening at %s');
});

使用cors库解决跨域的问题,但是在实际的使用中,cors并没有生效,跨域的问题依旧存在,这是怎么回事?

回到顶部