-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
74 lines (66 loc) · 2.23 KB
/
next.config.ts
File metadata and controls
74 lines (66 loc) · 2.23 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
// next.config.ts
import type { NextConfig } from "next";
/** 대표 도메인 (없으면 Vercel 프리뷰 기본값) */
const isProd = process.env.NODE_ENV === "production";
const RAW = process.env.SITE_URL ?? "https://myplanmate.vercel.app";
const ORIGIN = new URL(RAW);
const NON_WWW_HOST = ORIGIN.hostname.replace(/^www\./, "");
const WWW_HOST = ORIGIN.hostname.startsWith("www.") ? ORIGIN.hostname : `www.${NON_WWW_HOST}`;
const DEST_ORIGIN = `${ORIGIN.protocol}//${NON_WWW_HOST}`;
const nextConfig: NextConfig = {
reactStrictMode: true,
poweredByHeader: false, // x-powered-by: Next.js 헤더 제거
// 1) 외부 이미지 도메인 허용
images: {
domains: [
"images.unsplash.com",
"avatars.githubusercontent.com",
"lh3.googleusercontent.com",
// 필요하다면 여기 추가
],
remotePatterns: [
{
protocol: "https",
hostname: "**.supabase.co",
// TODO: Supabase 프로젝트 도메인 확정되면 "**.supabase.co" → "abcd.supabase.co"로 교체
// 위치: 대시보드 → Project Settings → Project URL (예: "abcd.supabase.co")
// 조치: hostname을 "abcd.supabase.co"로 바꿔 사용.
},
],
},
// 2) 보안 헤더 기본값 추가
async headers() {
return [
{
source: "/:path*",
headers: [
{ key: "X-Frame-Options", value: "DENY" }, // 클릭재킹 방지
{ key: "X-Content-Type-Options", value: "nosniff" }, // MIME 타입 스니핑 방지
{
key: "Referrer-Policy",
value: "strict-origin-when-cross-origin", // 안전한 referrer 전송
},
{
key: "Strict-Transport-Security",
value: "max-age=63072000; includeSubDomains; preload", // HTTPS 강제
},
],
},
];
},
// ✅ 슬래시 정책: 무슬래시
trailingSlash: false,
async redirects() {
// ⚠️ dev 모드(HMR)에서는 비활성화 (루프 방지)
if (!isProd) return [];
return [
{
source: "/:path*",
has: [{ type: "host", value: WWW_HOST }],
destination: `${DEST_ORIGIN}/:path*`,
permanent: false, // 검증 후 true로 승격
},
];
},
};
export default nextConfig;