Skip to content

Commit 6ec13d8

Browse files
committed
fix: CSP에 Google Analytics 수집 도메인 허용 추가
1 parent c10b816 commit 6ec13d8

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/middleware.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ const PUBLIC_FILE = /\.[^/]+$/
1212
const LOCALE_COOKIE_MAX_AGE = 60 * 60 * 24 * 365
1313

1414
function applySecurityHeaders(response: NextResponse, isDev: boolean): NextResponse {
15+
const analyticsHosts = "https://www.googletagmanager.com https://www.google-analytics.com https://region1.google-analytics.com"
16+
1517
const connectSrc = isDev
16-
? "'self' http://localhost:8080"
17-
: "'self'"
18+
? `'self' http://localhost:8080 ${analyticsHosts}`
19+
: `'self' ${analyticsHosts}`
1820

1921
const cspDirectives = [
2022
"default-src 'self'",
21-
"script-src 'self' 'unsafe-inline' 'unsafe-eval'",
23+
`script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.googletagmanager.com`,
2224
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
2325
"font-src 'self' https://fonts.gstatic.com",
24-
"img-src 'self' data: blob: https://avatars.githubusercontent.com https://github.com",
26+
"img-src 'self' data: blob: https://avatars.githubusercontent.com https://github.com https://www.google-analytics.com",
2527
`connect-src ${connectSrc}`,
2628
"frame-ancestors 'none'",
2729
"base-uri 'self'",

0 commit comments

Comments
 (0)