summaryrefslogtreecommitdiffstats
path: root/fatcat_scholar
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-02-11 19:30:05 -0800
committerBryan Newbold <bnewbold@archive.org>2021-02-11 19:30:05 -0800
commit191c137a4b2a475e3797df95711d583286910f72 (patch)
tree704c85a9ca764621ce3f5bfd957d5cee796f61ed /fatcat_scholar
parentc8ca2bcf4000af98f5b4ba8512d14049fce7fc7d (diff)
downloadfatcat-scholar-191c137a4b2a475e3797df95711d583286910f72.tar.gz
fatcat-scholar-191c137a4b2a475e3797df95711d583286910f72.zip
allow simple GET CORS requests
Diffstat (limited to 'fatcat_scholar')
-rw-r--r--fatcat_scholar/web.py9
1 files changed, 9 insertions, 0 deletions
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(