Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9337008
D8319.id30059.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D8319.id30059.diff
View Options
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
Details
Attached
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
Attached To
D8319: Enable cors in the asgi server
Event Timeline
Log In to Comment