Skip to content

Commit 782b43e

Browse files
authored
Merge pull request #44 from Brayden/bwilmoth/cors
Add the CORS file
2 parents ec2236e + 3baeff2 commit 782b43e

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)