Skip to content

Commit

Permalink
Adds CORS support. (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
conor-f committed Sep 1, 2023
1 parent ea80ef9 commit 9494155
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions fia_api/web/application.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from importlib import metadata

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import UJSONResponse
from tortoise.contrib.fastapi import register_tortoise

Expand Down Expand Up @@ -28,6 +29,14 @@ def get_app() -> FastAPI:
default_response_class=UJSONResponse,
)

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

# Adds startup and shutdown events.
register_startup_event(app)
register_shutdown_event(app)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ maintainers = [
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
python = "^3.10"
fastapi = "^0.100.0"
uvicorn = { version = "^0.22.0", extras = ["standard"] }
gunicorn = "^21.2.0"
Expand Down

0 comments on commit 9494155

Please sign in to comment.