Skip to content

Commit 7f64d83

Browse files
committed
Adding CORS
1 parent b6f2c59 commit 7f64d83

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

Diff for: server/requirements.txt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
aiohttp==3.6.2
2+
aiohttp-cors==0.7.0
3+
aiohttp-graphql==1.1.0
4+
aniso8601==7.0.0
5+
async-timeout==3.0.1
6+
attrs==19.3.0
7+
beautifulsoup4==4.8.2
8+
chardet==3.0.4
9+
graphene==2.1.8
10+
graphql-core==2.3.1
11+
graphql-relay==2.0.1
12+
graphql-server-core==1.2.0
13+
gunicorn==19.9.0
14+
idna==2.9
15+
multidict==4.7.5
16+
promise==2.3
17+
psycopg2-binary==2.8.4
18+
Rx==1.6.1
19+
six==1.14.0
20+
soupsieve==2.0
21+
Yapsy==1.12.2
22+
yarl==1.4.2

Diff for: server/routes.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import pathlib
22
from views import index
3+
import aiohttp_cors
34
from api.views import gqil_view, gql_view
45

56
def init_routes(app):
67
app.router.add_route('*', '/', index)
78
app.router.add_route('*', '/graphiql', gqil_view, name='graphiql')
89

9-
gql_resource = app.router.add_resource("/graphql")
10+
cors = aiohttp_cors.setup(app)
11+
gql_resource = cors.add(app.router.add_resource("/graphql"), {
12+
"*": aiohttp_cors.ResourceOptions(
13+
expose_headers="*",
14+
allow_headers="*",
15+
allow_credentials=True,
16+
allow_methods=["POST", "PUT", "GET"]),
17+
})
18+
1019
gql_resource.add_route("POST", gql_view)

Diff for: server/setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
install_requires = [
99
'psycopg2-binary==2.8.4',
1010
'aiohttp==3.6.2',
11+
'aiohttp_cors==0.7.0',
1112
'gunicorn==19.9.0',
1213
'graphql-core<3,>=2.1',
1314
'graphene==2.1.8',

0 commit comments

Comments
 (0)