diff --git a/store/app/main.py b/store/app/main.py index 6977e4be..01e06268 100644 --- a/store/app/main.py +++ b/store/app/main.py @@ -12,6 +12,15 @@ app = FastAPI() +# Adds CORS middleware. +app.add_middleware( + CORSMiddleware, + allow_origins=[settings.site.homepage], + allow_credentials=True, + allow_methods=["GET", "POST", "DELETE", "OPTIONS"], + allow_headers=["*"], +) + FRONTEND_DIR = (Path(__file__).parent / "frontend").resolve() if not (FRONTEND_BUILD_DIR := FRONTEND_DIR / "build").exists(): raise FileNotFoundError(f"Frontend is not built to {FRONTEND_BUILD_DIR}") @@ -47,13 +56,3 @@ async def redirect_to_index(full_path: str, request: Request) -> Response: if full_path in FRONTEND_OTHER_FILES: return await StaticFiles(directory=FRONTEND_BUILD_DIR).get_response(full_path, request.scope) return await StaticFiles(directory=FRONTEND_BUILD_DIR).get_response("index.html", request.scope) - - -# Adds CORS middleware. -app.add_middleware( - CORSMiddleware, - allow_origins=[settings.site.homepage], - allow_credentials=True, - allow_methods=["GET", "POST", "DELETE", "OPTIONS"], - allow_headers=["*"], -)