Add cors origins setting
This commit is contained in:
parent
b3e19b3e40
commit
815a4503df
2 changed files with 2 additions and 7 deletions
|
@ -48,12 +48,6 @@ logger = logging.getLogger("uvicorn.error")
|
||||||
templates = Jinja2Templates(Path(__file__).parent / "templates")
|
templates = Jinja2Templates(Path(__file__).parent / "templates")
|
||||||
|
|
||||||
|
|
||||||
origins = [
|
|
||||||
"https://tiptop:3002",
|
|
||||||
"https://philo.ydns.eu/",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def lifespan(app: FastAPI):
|
async def lifespan(app: FastAPI):
|
||||||
await get_providers_info()
|
await get_providers_info()
|
||||||
|
@ -65,7 +59,7 @@ app = FastAPI(title="OIDC auth test", lifespan=lifespan)
|
||||||
|
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
allow_origins=origins,
|
allow_origins=settings.cors_origins,
|
||||||
allow_credentials=True,
|
allow_credentials=True,
|
||||||
allow_methods=["*"],
|
allow_methods=["*"],
|
||||||
allow_headers=["*"],
|
allow_headers=["*"],
|
||||||
|
|
|
@ -113,6 +113,7 @@ class Settings(BaseSettings):
|
||||||
secret_key: str = "".join(random.choice(string.ascii_letters) for _ in range(16))
|
secret_key: str = "".join(random.choice(string.ascii_letters) for _ in range(16))
|
||||||
log: bool = False
|
log: bool = False
|
||||||
insecure: Insecure = Insecure()
|
insecure: Insecure = Insecure()
|
||||||
|
cors_origins: list[str] = []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def settings_customise_sources(
|
def settings_customise_sources(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue