Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow connections from localhost, regardless of CORS #15

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -42,6 +43,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