vercel 解决cors问题

网址

https://vercel.com/guides/how-to-enable-cors

代码

next.config.js文件

module.exports = {
  async headers() {
    return [
      {
        // matching all API routes
        source: "/api/:path*",
        headers: [
          { key: "Access-Control-Allow-Credentials", value: "true" },
          { key: "Access-Control-Allow-Origin", value: "*" },
          { key: "Access-Control-Allow-Methods", value: "GET,OPTIONS,PATCH,DELETE,POST,PUT" },
          { key: "Access-Control-Allow-Headers", value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" },
        ]
      }
    ]
  }
};


作者:spike

分类: Nodejs

创作时间:2024-01-26

更新时间:2024-01-26

联系方式放在中括号之中例如[[email protected]],回复评论在开头加上标号例如:#1
Copyright © Your Website 2024
介绍 赞助 Github Rss Sitemap 免责声明 联系