From e932b167318cbc6f218c5dc26ef793475a1f97c1 Mon Sep 17 00:00:00 2001 From: hyochan Date: Sat, 2 Nov 2024 20:30:37 +0900 Subject: [PATCH] feat: cors settings --- next.config.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/next.config.js b/next.config.js index 25eb29a..d4fc1b0 100644 --- a/next.config.js +++ b/next.config.js @@ -36,6 +36,31 @@ const nextConfig = { }, ], }, + { + source: '/api/:path*', // API 경로에 대해 CORS 헤더 추가 + headers: [ + {key: 'Access-Control-Allow-Credentials', value: 'true'}, + {key: 'Access-Control-Allow-Origin', value: '*'}, + { + key: 'Access-Control-Allow-Methods', + value: 'GET,OPTIONS,PATCH,DELETE,POST,PUT', + }, + { + 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', + }, + ], + }, + ]; + }, + + async rewrites() { + return [ + { + source: '/api/github-stats/:path*', + destination: 'https://stats.hyo.dev/api/github-stats/:path*', + }, ]; }, };