Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Commit

Permalink
configure allowable cors headers
Browse files Browse the repository at this point in the history
  • Loading branch information
marcolarosa committed Sep 25, 2023
1 parent 0aad4be commit f6d7ddb
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,38 @@ async function main() {
process.exit();
}

if (process.env.NODE_ENV === "development") {
fastify.register(cors, { origin: "*" });
}
fastify.register(fastifyIO);
await fastify.register(cors, {
origin: "*",
methods: ["OPTIONS", "GET", "HEAD", "PATCH", "POST", "DELETE"],
allowedHeaders: [
"content-type",
"upload-length",
"content-length",
"upload-offset",
"upload-expires",
"location",
"upload-metadata",
"tus-resumable",
"tus-version",
"tus-max-size",
"tus-extension",
],
exposedHeaders: [
"content-type",
"upload-length",
"content-length",
"upload-offset",
"upload-expires",
"location",
"upload-metadata",
"tus-resumable",
"tus-version",
"tus-max-size",
"tus-extension",
],
});
fastify.register(fastifySensible);
fastify.register(fastifyIO);
fastify.register(fastifyCompress);
fastify.register((fastify, options, done) => {
fastify.addHook("preHandler", async (req, res) => {
Expand Down

0 comments on commit f6d7ddb

Please sign in to comment.