Skip to content

Commit

Permalink
Set up origin list and added allow credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
cultpodcasts committed Apr 30, 2024
1 parent fbb792b commit 08730c5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ export interface Env {

export default {
async fetch(request: Request, env: Env) {
const allowedOrigins: Array<string> = ["https://cultpodcasts.com".toLowerCase(), "http://localhost:4200".toLowerCase()];
let origin = request.headers.get("Origin");
if (origin == null || allowedOrigins.indexOf(origin.toLowerCase()) == -1) {
origin = allowedOrigins[0];
}
const leechHandlingActive = false;
const { pathname, searchParams } = new URL(request.url);
const homeRoute = "/homepage";
const searchRoute = "/api";
const submitRoute = "/submit";
const corsHeaders = {
"Access-Control-Allow-Origin": "*", //"https://cultpodcasts.com",
"Access-Control-Allow-Origin": origin,
"Access-Control-Allow-Methods": "GET,HEAD,POST,OPTIONS",
"Access-Control-Max-Age": "86400",
"Access-Control-Allow-Headers": "content-type,authorization"
"Access-Control-Allow-Headers": "content-type,authorization",
"Access-Control-Allow-Credentials": "true"
};

if (request.method === "OPTIONS") {
Expand Down

0 comments on commit 08730c5

Please sign in to comment.