为/api/* 配置跨域#
next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
async headers() {
return [
{
source: "/api/(.*)",
headers: [{ key: "Access-Control-Allow-Origin", value: "*" }],
},
];
},
};
module.exports = nextConfig;