crossDomain.js 405 B

12345678910
  1. // 跨域中间件
  2. module.exports = (DOMAIN = '*') => {
  3. return (req, res, next) => {
  4. res.set('Access-Control-Allow-Headers', req.headers['access-control-request-headers']);
  5. res.header('Access-Control-Allow-Origin', req.headers.origin);
  6. res.header('Access-Control-Allow-Credentials', 'true');
  7. res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS');
  8. next();
  9. };
  10. };