CORS express not working predictably

前端 未结 6 1045
灰色年华
灰色年华 2021-02-08 08:15

I am trying to allow access from everywhere.

I have tried using app middleware:

app.use(function (req, res, next) {
  res.setHeader(\"Access-Control-Allo         


        
6条回答
  •  故里飘歌
    2021-02-08 08:54

    First install, the "cors" package from npm: npm i -S cors

    Then enable it in your express server.

    var express = require('express'),
      cors = require('cors');
    
    const app = express();
    app.use(cors());
    
    ...
    

提交回复
热议问题