Skip to content

Commit 2cac7bd

Browse files
committed
feat: adding cors to api routes open wide- to be changed
1 parent a3aa4eb commit 2cac7bd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

next.config.mjs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ const config = {
4646
config.resolve.fallback = { fs: false, net: false, tls: false };
4747
return config;
4848
},
49+
async headers() {
50+
return [
51+
{
52+
// matching all API routes
53+
source: "/api/:path*",
54+
headers: [
55+
{ key: "Access-Control-Allow-Credentials", value: "true" },
56+
{ key: "Access-Control-Allow-Origin", value: "*" },
57+
{
58+
key: "Access-Control-Allow-Methods",
59+
value: "GET,OPTIONS,PATCH,DELETE,POST,PUT",
60+
},
61+
{
62+
key: "Access-Control-Allow-Headers",
63+
value:
64+
"X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version",
65+
},
66+
],
67+
},
68+
];
69+
},
4970
};
5071

5172
export default withMDX(config);

0 commit comments

Comments
 (0)