-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
120 lines (118 loc) · 3.66 KB
/
Copy pathnext.config.ts
File metadata and controls
120 lines (118 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
// 같은 저장소에서 dev 서버와 build를 동시에 돌리면 .next를 서로 덮어써 런타임이 깨진다.
// NEXT_DIST_DIR로 각자 다른 디렉터리를 쓰게 해두면 병행 작업이 가능하다. (기본값은 그대로 .next)
distDir: process.env.NEXT_DIST_DIR || '.next',
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'silverithm.site',
},
{
protocol: 'http',
hostname: 'localhost',
},
],
},
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN', // DENY에서 SAMEORIGIN으로 변경하여 링크 미리보기 허용
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
{
key: 'Permissions-Policy',
value: 'camera=(), microphone=(), geolocation=()',
},
],
},
{
// 관리자 및 결제 페이지에만 강한 보안 적용
source: '/(admin|payment)/:path*',
headers: [
{
key: 'X-Frame-Options',
value: 'DENY', // 민감한 페이지는 여전히 DENY 유지
},
],
},
{
// 셀프호스팅 rhwp-studio의 해시된 에셋(wasm/js/css) — 파일명에 해시가 있어 영구 캐시 가능
source: '/rhwp-studio/assets/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
{
// 정적 이미지(파일명에 해시 없음) — 기본값(max-age=0)은 재방문마다 조건부 요청을 만든다.
// 하루 캐시 + 일주일 stale-while-revalidate로 교체 시 지연 노출 위험 없이 재방문을 빠르게.
source: '/images/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=86400, stale-while-revalidate=604800',
},
],
},
{
// 결제 페이지에 대한 추가 보안 헤더
source: '/payment/:path*',
headers: [
{
key: 'Cache-Control',
value: 'no-store, no-cache, must-revalidate, proxy-revalidate',
},
{
key: 'Pragma',
value: 'no-cache',
},
{
key: 'Expires',
value: '0',
},
],
},
// 로그인 이후에만 의미가 있는 화면은 검색결과에 노출되지 않도록 한다.
// robots.txt의 Disallow는 크롤링만 막을 뿐, 외부 링크로 발견되면 URL이 색인될 수 있다.
...['/admin', '/employee', '/payment', '/subscription', '/subscription-check', '/dev-sched-preview'].flatMap(
(path) => [
{
source: path,
headers: [{ key: 'X-Robots-Tag', value: 'noindex, nofollow' }],
},
{
source: `${path}/:path*`,
headers: [{ key: 'X-Robots-Tag', value: 'noindex, nofollow' }],
},
]
),
];
},
async redirects() {
return [
// www는 같은 사이트를 그대로 서빙해 중복 문서가 된다. 대표 호스트로 통합.
{
source: '/:path*',
has: [{ type: 'host', value: 'www.carev.kr' }],
destination: 'https://carev.kr/:path*',
permanent: true,
},
];
},
};
export default nextConfig;