From a5e6f903bf7f003e8c7091dce4a2787f8c7ebfaa Mon Sep 17 00:00:00 2001 From: hanfi <ccc@spahan.ch> Date: Fri, 16 Jun 2023 08:23:17 +0200 Subject: [PATCH] make CORS URLs configurable --- backend/config.py | 3 +++ backend/main.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/config.py b/backend/config.py index 88b58c6..313984a 100644 --- a/backend/config.py +++ b/backend/config.py @@ -5,6 +5,9 @@ class Settings(BaseSettings): # we may want use DSN validators from pydantic. # but there are no sqlite validators? database_url: str = "sqlite:///./paketshop.db" + backend_url: str = "http://localhost:8000" + customer_url: str = "http://localhost:3000" + worker_url: str = "http://localhost:3002" class Config: env_file = ".env" diff --git a/backend/main.py b/backend/main.py index 3b9af59..af974d8 100644 --- a/backend/main.py +++ b/backend/main.py @@ -5,13 +5,14 @@ from fastapi.middleware.cors import CORSMiddleware from sqlalchemy.orm import Session from . import schemas, utils +from .config import settings from .database import SessionLocal, create_database create_database() app = FastAPI() -origins = ["http://127.0.0.1:8000", "http://localhost:3000", "http://localhost:3002"] +origins = [settings.customer_url, settings.worker_url] app.add_middleware( -- GitLab