Graphene-django: getting '405 Method Not Allowed' when Apollo client sends OPTIONS method

Created on 10 Oct 2017  Â·  5Comments  Â·  Source: graphql-python/graphene-django

in response headers I see "Allow: GET, POST". How can I enable OPTIONS method on server?

Most helpful comment

@dsun-ge
With the same issue, I figured out that I forgot to add
'corsheaders.middleware.CorsMiddleware',
in the middleware section:
MIDDLEWARE = [ # Or MIDDLEWARE_CLASSES on Django < 1.10 ... 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', ... ]

All 5 comments

sorry, using corsheaders fixed my issue.

can you provide a usage sample?

I've just used corsheaders and followed their documentation

@slavugan I also followed django-cors-headers's instructions and set CORS_ORIGIN_ALLOW_ALL = True.

And

OPTIONS http://my-django-graphene-site/admin

returns "access-control-allow-origin →*". This means the cors-header is working. However,

OPTIONS http://my-django-graphene-site/graphql

returns error saying "only POST and GET are allowed", and POST returned no "access-control-allow-origin" header.

Could you show us how you enable OPTIONS method for graphql?

@dsun-ge
With the same issue, I figured out that I forgot to add
'corsheaders.middleware.CorsMiddleware',
in the middleware section:
MIDDLEWARE = [ # Or MIDDLEWARE_CLASSES on Django < 1.10 ... 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', ... ]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

flame0 picture flame0  Â·  4Comments

artofhuman picture artofhuman  Â·  3Comments

BrianChapman picture BrianChapman  Â·  3Comments

licx picture licx  Â·  3Comments

x9sheikh picture x9sheikh  Â·  4Comments