next.config.js 里配置
- /** @type {import('next').NextConfig} */
- const nextConfig = {
- async headers() {
- return [
- {
- source: "/api/(.*)",
- headers: [
- {
- key: "Access-Control-Allow-Origin",
- value: "*",
- },
- {
- key: "Access-Control-Allow-Methods",
- value: "GET, POST, PUT, DELETE, OPTIONS",
- },
- {
- key: "Access-Control-Allow-Headers",
- value: "Content-Type, Authorization",
- },
- ],
- },
- ];
- },
- };
- module.exports = nextConfig
复制代码
参考自:https://codingwithmanny.medium.c ... ndlers-427e10929818 |