-
Notifications
You must be signed in to change notification settings - Fork 0
/
_middleware.ts
34 lines (30 loc) · 992 Bytes
/
_middleware.ts
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
import { NextResponse } from 'next/server';
export function middleware() {
const ContentSecurityPolicy = `
default-src 'self';
script-src 'self' 'unsafe-inline' 'unsafe-eval';
style-src 'self' 'unsafe-inline';
img-src * blob: data:;
media-src 'none';
connect-src *;
font-src 'self';
`;
const response = NextResponse.next();
response.headers.set(
'Content-Security-Policy',
ContentSecurityPolicy.replace(/\n/g, '')
);
response.headers.set('Referrer-Policy', 'origin-when-cross-origin');
response.headers.set(
'Permissions-Policy',
'camera=(), microphone=(), geolocation=()'
);
response.headers.set(
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains; preload'
);
response.headers.set('X-Frame-Options', 'DENY');
response.headers.set('X-Content-Type-Options', 'nosniff');
response.headers.set('X-DNS-Prefetch-Control', 'on');
return response;
}