Skip to content

Commit

Permalink
Fix cors middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
brachkow committed May 9, 2024
1 parent 2eef5a0 commit 96b8871
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
18 changes: 18 additions & 0 deletions functions/_middleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const onRequestOptions = async () => {
return new Response(null, {
status: 204,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Methods': 'GET, OPTIONS',
'Access-Control-Max-Age': '86400',
},
});
};

export const onRequest = async ({ next }) => {
const response = await next();
response.headers.set('Access-Control-Allow-Origin', '*');
response.headers.set('Access-Control-Max-Age', '86400');
return response;
};
8 changes: 0 additions & 8 deletions functions/_middleware.ts

This file was deleted.

0 comments on commit 96b8871

Please sign in to comment.