-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
27 lines (23 loc) · 763 Bytes
/
Copy pathnext.config.ts
File metadata and controls
27 lines (23 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import type { NextConfig } from "next";
const allowedOrigins = (process.env.ALLOWED_ORIGINS || "")
.split(",")
.map((origin) => origin.trim())
.filter(Boolean);
const nextConfig: NextConfig = {
trailingSlash: true,
async headers() {
if (allowedOrigins.length !== 1) return [];
return [
{
source: "/api/:path*",
headers: [
{ key: "Access-Control-Allow-Credentials", value: "true" },
{ key: "Access-Control-Allow-Origin", value: allowedOrigins[0] },
{ key: "Access-Control-Allow-Methods", value: "GET, POST, PUT, DELETE, PATCH, OPTIONS" },
{ key: "Access-Control-Allow-Headers", value: "Authorization, Content-Type" },
],
},
];
},
};
export default nextConfig;