Page MenuHomeSoftware Heritage

D8319.id30059.diff
No OneTemporary

D8319.id30059.diff

diff --git a/requirements-dev.txt b/requirements-dev.txt
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1 +1,2 @@
uvicorn
+starlette
diff --git a/swh/graphql/server.py b/swh/graphql/server.py
--- a/swh/graphql/server.py
+++ b/swh/graphql/server.py
@@ -57,12 +57,10 @@
def make_app_from_configfile():
- """Loading the configuration from
- a configuration file.
+ """Loading the configuration from a configuration file.
SWH_CONFIG_FILENAME environment variable defines the
configuration path to load.
-
"""
from .app import schema
@@ -75,8 +73,14 @@
server_type = graphql_cfg.get("server-type")
if server_type == "asgi":
from ariadne.asgi import GraphQL
-
- application = GraphQL(schema)
+ from starlette.middleware.cors import CORSMiddleware
+
+ # Enable cors in the asgi version
+ application = CORSMiddleware(
+ GraphQL(schema),
+ allow_origins=["*"],
+ allow_methods=("GET", "POST", "OPTIONS"),
+ )
else:
from ariadne.wsgi import GraphQL

File Metadata

Mime Type
text/plain
Expires
Jul 3 2025, 7:50 AM (10 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3215829

Event Timeline