diff --git a/main.py b/main.py index 6f7ce5b..3ab9393 100644 --- a/main.py +++ b/main.py @@ -48,26 +48,11 @@ async def lifespan(app: FastAPI): no_docs = os.getenv("ENVIRONMENT") == "production" dev_origins = [ - "http://localhost:3000", # If we don't specify port, it defaults to 80 - "http://127.0.0.1:3000", - "http://localhost:3001", # Sometimes VSCode thinks 3000 is used, so the frontend uses a higher port - "http://127.0.0.1:3001", # Wildcard ports don't work with cookies so we need this cursed mess :( - "http://localhost:3002", - "http://127.0.0.1:3002", - "http://localhost:3003", - "http://127.0.0.1:3003", + "http://localhost", # Idk if this is even needed ] stage_origins = [ "https://stage.frontend.fsektionen.se", - "http://localhost:3000", # If we don't specify port, it defaults to 80 - "http://127.0.0.1:3000", - "http://localhost:3001", # Sometimes VSCode thinks 3000 is used, so the frontend uses a higher port - "http://127.0.0.1:3001", - "http://localhost:3002", - "http://127.0.0.1:3002", - "http://localhost:3003", - "http://127.0.0.1:3003", ] production_origins = ["https://fsektionen.se"] @@ -86,6 +71,7 @@ async def lifespan(app: FastAPI): allow_credentials=True, allow_methods=["*"], allow_headers=["*"], + allow_origin_regex="\bhttp://(localhost|127\.0\.0\.1):(\d+)\b", # Allow all localhost origins with any port ) if os.getenv("ENVIRONMENT") == "stage": @@ -95,6 +81,7 @@ async def lifespan(app: FastAPI): allow_credentials=True, allow_methods=["*"], allow_headers=["*"], + allow_origin_regex="\bhttp://(localhost|127\.0\.0\.1):(\d+)\b", # Allow all localhost origins with any port ) if os.getenv("ENVIRONMENT") == "production":