Skip to content

Commit

Permalink
Added cors that I forgot
Browse files Browse the repository at this point in the history
  • Loading branch information
jLynx committed Jan 11, 2024
1 parent 56e4aaf commit 8c88bfb
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions functions/api/fetch_nightly_firmware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const corsHeaders = {
"Access-Control-Allow-Methods": "GET,HEAD,POST,OPTIONS,DELETE",
"Access-Control-Allow-Headers": "Content-Type",
"Access-Control-Max-Age": "86400",
"Content-Type": "application/json;charset=utf-8",
};

export const onRequestGet: PagesFunction = async (context) => {
Expand Down Expand Up @@ -34,12 +33,10 @@ export const onRequestGet: PagesFunction = async (context) => {

let fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);

// You can modify the response here, like setting content-disposition to force a file download
response = new Response(response.body, response);
response.headers.set(
"Content-Disposition",
`attachment; filename="${fileName}"`
);

return response;
return new Response(response.body, {
headers: {
...corsHeaders,
"Content-Disposition": `attachment; filename="${fileName}"`,
},
});
};

0 comments on commit 8c88bfb

Please sign in to comment.