fix: correct cross-origin handling
This commit is contained in:
@@ -4,7 +4,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
class Settings(BaseSettings):
|
||||
app_title: str = "PepperPlus"
|
||||
|
||||
ui_url: HttpUrl = HttpUrl("http://localhost:5173")
|
||||
ui_url: str = "http://localhost:5173"
|
||||
|
||||
model_config = SettingsConfigDict(env_file=".env")
|
||||
|
||||
|
||||
@@ -22,15 +22,16 @@ async def lifespan(app: FastAPI):
|
||||
|
||||
# if __name__ == "__main__":
|
||||
app = FastAPI(title=settings.app_title, lifespan=lifespan)
|
||||
app.include_router(api_router, prefix="") # TODO: make prefix /api/v1
|
||||
|
||||
# This middleware allows other origins to communicate with us
|
||||
app.add_middleware(
|
||||
CORSMiddleware, # https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
|
||||
allow_origins=[settings.ui_url.unicode_string()], # address of our UI application
|
||||
allow_origins=[settings.ui_url], # address of our UI application
|
||||
allow_methods=["*"], # GET, POST, etc.
|
||||
)
|
||||
|
||||
app.include_router(api_router, prefix="") # TODO: make prefix /api/v1
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"status": "ok"}
|
||||
Reference in New Issue
Block a user