Skip to content

Commit

Permalink
Set web security headers
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmytton authored and haydenbleasel committed Dec 11, 2024
1 parent c98ca07 commit 43c23e1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions apps/web/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { authMiddleware } from '@repo/auth/middleware';
import { env } from '@repo/env';
import { parseError } from '@repo/observability/error';
import { secure } from '@repo/security';
import { noseconeConfig, noseconeMiddleware } from '@repo/security/middleware';
import { NextResponse } from 'next/server';

export const config = {
Expand All @@ -10,9 +11,11 @@ export const config = {
matcher: ['/((?!_next/static|_next/image|ingest|favicon.ico).*)'],
};

const securityHeaders = noseconeMiddleware(noseconeConfig);

export default authMiddleware(async (_auth, request) => {
if (!env.ARCJET_KEY) {
return NextResponse.next();
return securityHeaders();
}

try {
Expand All @@ -26,7 +29,7 @@ export default authMiddleware(async (_auth, request) => {
request
);

return NextResponse.next();
return securityHeaders();
} catch (error) {
const message = parseError(error);

Expand Down

0 comments on commit 43c23e1

Please sign in to comment.