Monorepo for Aesthetic.Computer
aesthetic.computer
1// TODO: - [] Update `say` with this function also...
2
3export function corsHeaders(request) {
4 const dev = process.env.VERCEL_ENV === "development";
5 const production = !dev;
6
7 const allowedOrigins = ["https://aesthetic.computer", "https://botce.ac"];
8
9 // If in production, check the request's origin against allowedOrigins.
10 // If there's a match, set that as the Access-Control-Allow-Origin value.
11 // If in development, simply use the wildcard.
12 let originToSet;
13 // console.log("Origin:", request.headers.get("origin"));
14 if (production) {
15 if (
16 request.headers &&
17 allowedOrigins.includes(request.headers.get("origin"))
18 ) {
19 originToSet = request.headers.get("origin");
20 } else {
21 originToSet = allowedOrigins[0]; // Default to the first one if no match
22 }
23 } else {
24 originToSet = "*";
25 }
26
27 return {
28 "Access-Control-Allow-Methods": "GET,OPTIONS,PATCH,DELETE,POST,PUT",
29 "Access-Control-Allow-Origin": originToSet,
30 "Access-Control-Allow-Headers":
31 "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version",
32 };
33}