Skip to content

Commit

Permalink
fix: CORS configuration (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjibansg committed Feb 19, 2024
1 parent 1eec522 commit 8e99a4e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from duckdb import DuckDBPyConnection
from fastapi import (Depends, FastAPI, File, Form, HTTPException, UploadFile,
status)
from fastapi.middleware.trustedhost import TrustedHostMiddleware
from fastapi.middleware.cors import CORSMiddleware
from fastapi.openapi.utils import get_openapi
from fastapi.routing import APIRouter
from fastapi_health import health
Expand Down Expand Up @@ -276,9 +276,19 @@ def substrait_fiddle_openapi():
app = FastAPI()
app.include_router(router, prefix="/api/route")
app.openapi = substrait_fiddle_openapi

origins = [
"http://localhost",
"http://localhost:80",
"http://substrait-fiddle.com",
]

app.add_middleware(
TrustedHostMiddleware,
allowed_hosts=["*"],
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

@app.get("/")
Expand Down

0 comments on commit 8e99a4e

Please sign in to comment.