Skip to content

Commit 263c893

Browse files
authored
Add HSTS and other security headers (GitbookIO#2271)
1 parent ebf742e commit 263c893

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/middleware.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ export async function middleware(request: NextRequest) {
235235

236236
// Add Content Security Policy header
237237
response.headers.set('content-security-policy', csp);
238+
// Basic security headers
239+
response.headers.set('strict-transport-security', 'max-age=31536000');
240+
response.headers.set('referrer-policy', 'no-referrer-when-downgrade');
241+
response.headers.set('x-content-type-options', 'nosniff');
238242

239243
const isPrefetch = request.headers.has('x-middleware-prefetch');
240244

0 commit comments

Comments
 (0)