From 191c137a4b2a475e3797df95711d583286910f72 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 11 Feb 2021 19:30:05 -0800 Subject: allow simple GET CORS requests --- fatcat_scholar/web.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'fatcat_scholar') diff --git a/fatcat_scholar/web.py b/fatcat_scholar/web.py index 31ee617..8a1faa7 100644 --- a/fatcat_scholar/web.py +++ b/fatcat_scholar/web.py @@ -13,6 +13,7 @@ import babel.support from fastapi import FastAPI, APIRouter, Request, Depends, Response, HTTPException from fastapi.staticfiles import StaticFiles from fastapi.responses import PlainTextResponse, JSONResponse, FileResponse +from fastapi.middleware.cors import CORSMiddleware import sentry_sdk from sentry_sdk.integrations.asgi import SentryAsgiMiddleware from starlette_prometheus import metrics, PrometheusMiddleware @@ -322,6 +323,14 @@ async def http_exception_handler(request: Request, exc: StarletteHTTPException) # configure middleware +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=False, + allow_methods=["GET"], + allow_headers=[], # some defaults always enabled +) + if settings.SENTRY_DSN: logger.info("Sentry integration enabled") sentry_sdk.init( -- cgit v1.2.3