Skip to content

Commit 7949e38

Browse files
committed
chore: post
1 parent a18eaad commit 7949e38

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

modules/wait/mod.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ export default function (s: Fastro) {
4343
},
4444
});
4545
});
46+
s.options("/api/v1/post", (req, ctx) => {
47+
return new Response(null, {
48+
status: 204,
49+
headers: {
50+
"Access-Control-Allow-Origin": "*", // Allow requests from any origin
51+
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
52+
"Access-Control-Allow-Headers": "Content-Type, Authorization",
53+
},
54+
});
55+
});
4656
s.post("/api/v1/post", async (req, ctx) => {
4757
console.log("Handling post request");
4858
const headers = {
@@ -53,14 +63,6 @@ export default function (s: Fastro) {
5363
"Access-Control-Max-Age": "86400", // 24 hours cache for preflight requests
5464
};
5565

56-
// Handle preflight OPTIONS request
57-
if (req.method === "OPTIONS") {
58-
console.log("Handling preflight OPTIONS request");
59-
return new Response(null, {
60-
status: 204,
61-
headers,
62-
});
63-
}
6466
let responseBody = {};
6567
let responseStatus = 200;
6668

0 commit comments

Comments
 (0)