Add cors headers to all api routes, with deployment as origin

This commit is contained in:
austinkelsay 2024-10-01 17:52:38 -05:00
parent dc61827f86
commit a8c9ab7f68
2 changed files with 21 additions and 2 deletions

View File

@ -24,6 +24,27 @@ module.exports = removeImports({
}
];
},
async headers() {
return [
{
source: "/api/:path*",
headers: [
{
key: "Access-Control-Allow-Origin",
value: "https://plebdevs-three.vercel.app", // Set your origin
},
{
key: "Access-Control-Allow-Methods",
value: "GET, POST, PUT, DELETE, OPTIONS",
},
{
key: "Access-Control-Allow-Headers",
value: "Content-Type, Authorization",
},
],
},
];
},
env: {
KV_URL: process.env.NODE_ENV !== 'production'
? process.env.REDIS_URL

View File

@ -53,8 +53,6 @@ export default async function middleware(request) {
`ratelimit_middleware_${ip}`
);
console.log("headers", request.headers)
if (!success) {
return new NextResponse('Too Many Requests', {
status: 429,