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