Skip to content

Commit 3baeff2

Browse files
committed
Add the CORS file
1 parent 7266a94 commit 3baeff2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/cors.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const corsHeaders = {
2+
'Access-Control-Allow-Origin': '*',
3+
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
4+
'Access-Control-Allow-Headers': 'Authorization, Content-Type, X-Starbase-Source',
5+
'Access-Control-Max-Age': '86400',
6+
};
7+
8+
export function corsPreflight(request: Request) {
9+
// Handle OPTIONS preflight request first
10+
if (request.method === 'OPTIONS') {
11+
return new Response(null, {
12+
status: 204,
13+
headers: corsHeaders
14+
});
15+
}
16+
}

0 commit comments

Comments
 (0)