Skip to content

Commit be4f106

Browse files
committed
chore: Update next.config.mjs and vercel.json to implement CORS headers for API routes and enhance routing consistency
1 parent bd2b885 commit be4f106

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

next.config.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
/** @type {import('next').NextConfig} */
2-
const nextConfig = {}
2+
const nextConfig = {
3+
trailingSlash: false, // Consistent handling
4+
async headers() {
5+
return [
6+
{
7+
source: "/api/:path*",
8+
headers: [
9+
{ key: "Access-Control-Allow-Origin", value: "*" },
10+
{ key: "Access-Control-Allow-Methods", value: "GET, OPTIONS" },
11+
{ key: "Access-Control-Allow-Headers", value: "Content-Type" },
12+
],
13+
},
14+
]
15+
},
16+
}
317

418
export default nextConfig

vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"headers": [
33
{
4-
"source": "/api/(.*)",
4+
"source": "/api/:path*",
55
"headers": [
66
{ "key": "Access-Control-Allow-Origin", "value": "*" },
77
{ "key": "Access-Control-Allow-Methods", "value": "GET, OPTIONS" },

0 commit comments

Comments
 (0)