Zeit (Vercel) Now serverless authenticated requests failing because of CORS

后端 未结 5 1856
梦谈多话
梦谈多话 2021-02-20 02:17

I\'m not able to correctly handle CORS issues when doing either PATCH/POST/PUT requests from the browser sending an Authorization

5条回答
  •  情话喂你
    2021-02-20 02:33

    I faced a similar problem and the problem was solved byadding the header to the routes as follows:

    "routes": [
        {
          "src": ".*",
          "methods": ["GET", "POST", "OPTIONS"],
          "headers": {
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept",
            "Access-Control-Allow-Credentials": "true"
          },
          "dest": "index.js",
          "continue": true
        },
        {
          "src": "/user/login", "methods": ["POST"], "dest": "index.js"
        }
      ]
    

    remember to add continue: true.

    https://github.com/super-h-alt/zeit-now-cors-problems/blob/master/now.json

提交回复
热议问题