Skip to content

Commit

Permalink
fix: preflight request
Browse files Browse the repository at this point in the history
  • Loading branch information
alan16742 committed Oct 12, 2024
1 parent eef916b commit 163e471
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions back-end-cf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ async function handleRequest(request) {
return Response.redirect(url, 302);
}

// preflight
if(request.method === 'OPTIONS') {
return new Response(null, {
status: 204,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Max-Age': '86400',
}
});
}

const returnHeaders = {
'Access-Control-Allow-Origin': '*',
'Cache-Control': 'max-age=3600',
Expand Down

0 comments on commit 163e471

Please sign in to comment.