Skip to content

How to enable CORS for subscriptions when mounted under Starlette/FastAPI ? #568

Answered by rafalp
AlexMili asked this question in Q&A
Discussion options

You must be logged in to vote

Hey!

This isn't documented anywhere on Starlette's site but you are supposed to mount WebSocket app separately:

app.mount("/graphql/", graphql)
app.add_websocket_route("/graphql/", graphql.websocket_server)

Your error 403 in fact is not caused by CORS (because those don't apply to the Websocket connections!) - its refusal of protocol by the server that gives 403 here.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AlexMili
Comment options

Answer selected by AlexMili
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants