Skip to content

Commit c009ac6

Browse files
committed
fix: cors error
1 parent ead157e commit c009ac6

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

next.config.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
/** @type {import('next').NextConfig} */
2-
const nextConfig = {}
2+
const nextConfig = {
3+
async headers() {
4+
return [
5+
{
6+
// matching all API routes
7+
source: '/:path*',
8+
headers: [
9+
{ key: 'Access-Control-Allow-Credentials', value: 'true' },
10+
{ key: 'Access-Control-Allow-Origin', value: '*' },
11+
{ key: 'Access-Control-Allow-Methods', value: 'GET,OPTIONS,PATCH,DELETE,POST,PUT' },
12+
{ key: 'Access-Control-Allow-Headers', value: 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, Authorization' },
13+
],
14+
},
15+
];
16+
},
17+
};
318

4-
module.exports = nextConfig
19+
module.exports = nextConfig;

vercel.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"headers": [
3+
{
4+
"source": "/api/(.*)",
5+
"headers": [
6+
{ "key": "Access-Control-Allow-Credentials", "value": "true" },
7+
{ "key": "Access-Control-Allow-Origin", "value": "*" },
8+
{ "key"
9+
:
10+
"Access-Control-Allow-Methods",
11+
" valor": "GET,OPTIONS,PATCH,DELETE,POST,PUT"
12+
},
13+
{
14+
"key": "Access-Control-Allow-Headers",
15+
"value": "X-CSRF-Token, X-Requested-With, Aceitar, Aceitar versão, Comprimento do conteúdo, Conteúdo-MD5, Tipo de conteúdo, Data, Versão X-Api"
16+
}
17+
]
18+
}
19+
]
20+
}

0 commit comments

Comments
 (0)