CORS?
Closed this issue · 4 comments
Hi. Does this support CORS? I could't find any mention of it or headers like Access-Control-Allow-Origin
.
Could you give me an example of setting the CORS headers?
Thanks
This library provides an example server that doesn't allow you to customize the response headers:
ocaml-graphql-server/graphql-lwt/src/graphql_lwt.ml
Lines 44 to 46 in 4367e7f
However, as I found in my own projects, that is not enough and you'll need to write your own server that calls into the constructs provided by Graphql_schema
. This function is a good starting point to writing your own:
Adding custom HTTP headers to the response will be a lot easier once this PR is merged: #126
In the meantime you can either take the approach described by @anmonteiro, or have Nginx in front and add CORS headers there (that's what I do).
graphql-cohttp
is now a thing. This can probably be closed?
I'll close this one. Feel free to open a PR against graphql-cohttp
with CORS support 😄