-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmiddleware.ts
More file actions
33 lines (29 loc) · 1.08 KB
/
Copy pathmiddleware.ts
File metadata and controls
33 lines (29 loc) · 1.08 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
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function middleware(request: NextRequest) {
const response = NextResponse.next()
// Security Headers
response.headers.set('X-Frame-Options', 'DENY')
response.headers.set('X-Content-Type-Options', 'nosniff')
response.headers.set('Referrer-Policy', 'strict-origin-when-cross-origin')
response.headers.set('Permissions-Policy', 'camera=(), microphone=(), geolocation=()')
response.headers.set('Strict-Transport-Security', 'max-age=31536000; includeSubDomains')
response.headers.set(
'Content-Security-Policy',
[
"default-src 'self'",
"img-src 'self' data: https: blob:",
"script-src 'self' 'unsafe-eval' 'unsafe-inline'",
"style-src 'self' 'unsafe-inline'",
"font-src 'self' data:",
"connect-src 'self' https://t.me https://instagram.com https://www.google-analytics.com",
"frame-src 'none'",
"frame-ancestors 'none'",
"form-action 'self'",
].join('; ')
)
return response
}
export const config = {
matcher: '/:path*',
}