Skip to content

Commit

Permalink
Allow connections from localhost, regardless of CORS (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
kerinin authored Jan 26, 2024
1 parent cda4f8b commit 52b685b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dewy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import asyncpg
from fastapi import FastAPI
from loguru import logger
from fastapi.middleware.cors import CORSMiddleware

from dewy.common import db
from dewy.config import app_configs, settings
Expand Down Expand Up @@ -36,6 +37,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 52b685b

Please sign in to comment.