Skip to content

Commit 1865ebb

Browse files
committed
modify(#252):서브도메인 리다이렉트 수정
1 parent 7ed1cab commit 1865ebb

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

next.config.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,19 @@ const nextConfig = {
3434
// ];
3535
// },
3636
//강제 리다이렉트 실행
37-
async middleware() {
38-
return ['./src/middleware'];
39-
},
4037
rewrites() {
41-
return {
42-
beforeFiles: [
43-
{
44-
source: '/:path*',
45-
has: [
46-
{
47-
type: 'host',
48-
value: 'www.menbosha.kr',
49-
},
50-
],
51-
destination: 'https://menbosha.kr/:path*',
52-
},
53-
],
54-
};
38+
return [
39+
{
40+
source: '/:path*',
41+
has: [
42+
{
43+
type: 'host',
44+
value: 'www.menbosha.kr',
45+
},
46+
],
47+
destination: '//:path*',
48+
},
49+
];
5550
},
5651
generateEtags: false,
5752
images: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "next dev",
6+
"dev": "env-cmd -f .env.development next dev",
77
"dev:mock": "env-cmd -f .env.mock next dev",
88
"build": "next build",
99
"start": "next start",

src/middleware.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,16 @@ export function middleware(req: IncomingMessage, res: ServerResponse) {
1515
}
1616
}
1717
}
18+
19+
export const config = {
20+
matcher: [
21+
/*
22+
* 아래와 같이 시작하는 것들을 제외한 모두 경로를 매치합니다:
23+
* - api (API routes)
24+
* - _next/static (static files)
25+
* - _next/image (image optimization files)
26+
* - favicon.ico (favicon file)
27+
*/
28+
'/((?!api|_next/static|_next/image|favicon.ico).*)',
29+
],
30+
};

0 commit comments

Comments
 (0)