安装
npm install cors -S
配置
在app.js文件中配置cors
var cors=require('cors')
app.use(cors())
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var cors=require('cors')var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');var app = express();app.use(cors())
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');