Skip to content

Commit

Permalink
Add OPTIONS method and X-CSRF-Token to middleware
Browse files Browse the repository at this point in the history
The OPTIONS HTTP method has been added to the 'Access-Control-Allow-Methods' in the middleware. Additionally, 'X-CSRF-Token' is now included in the 'Access-Control-Allow-Headers'. These changes ensure more robust handling of CORS and CSRF protection.
  • Loading branch information
claygorman committed Dec 11, 2023
1 parent 419c1aa commit 1a7baa1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frontend/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export function middleware(req: NextRequest) {
);
res.headers.append(
'Access-Control-Allow-Methods',
'GET,DELETE,PATCH,POST,PUT'
'GET,OPTIONS,DELETE,PATCH,POST,PUT'
);
res.headers.append(
'Access-Control-Allow-Headers',
'Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, Apollo-Require-Preflight, Origin, X-Requested-With, Authorization'
'Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, Apollo-Require-Preflight, Origin, X-Requested-With, Authorization, X-CSRF-Token'
);
} else {
// generic CORS policy omitted for brevity....
Expand Down

0 comments on commit 1a7baa1

Please sign in to comment.