Skip to content

Commit

Permalink
Allow connections from localhost, regardless of CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
kerinin committed Jan 25, 2024
1 parent e8c7e3d commit be7ca03
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import asyncpg
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from app.common import db
from app.config import app_configs, settings
Expand Down Expand Up @@ -38,6 +39,16 @@ async def lifespan(_app: FastAPI) -> AsyncIterator[State]:

app = FastAPI(lifespan=lifespan, **app_configs)

origins = [
"http://localhost:5173",
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

@app.get("/healthcheck", include_in_schema=False)
async def healthcheck() -> dict[str, str]:
Expand Down

0 comments on commit be7ca03

Please sign in to comment.