How to handle cross origin?
Why do we do that?
Browser will poke cross site server with OPTIONS
method to determine the access right.
If browser don't see the right header, then it won't take the data.
If server side don't handle
OPTIONS
method correctly, a server side exception may be raised.
REST
Repository : https://github.com/ccapeng/bookstore_openapi
To handle corss site origin
request
andresponse
, implement middlewarecorsapp.middleware.CorsMiddleware
And adjust settings in
bookstore_openapi.settings.py
To bypass cross origin, 3 access control attributes were added to
response
.
GraphQL
Repository : https://github.com/ccapeng/bookstore_graphQL
To handle corss site origin
request
andresponse
, implement middlewarecorsapp.middleware.CorsMiddleware
And adjust settings in
bookstore_graphql.settings.py
To bypass cross origin, 3 access control attributes were added to
response
.
gRPC
Last updated