View Source GRPC.Server.Interceptors.CORS (grpc v0.10.1)
Sends CORS headers when the client is using RPC via Web transcoding or gRPC-web.
Options
:allow_origin
- Required. A string containing the allowed origin, or a function capture (e.g.&MyApp.MyModule.function/2)
) which takes areq
and astream
and returns a string.:allow_headers
- A string containing the allowed headers, or a function capture (e.g.&MyApp.MyModule.function/2)
) which takes areq
and astream
and returns a string. Defaults tonil
. If defined asnil
, the value of the"access-control-request-headers"
request header from the client will be used in the response.
Usage
defmodule Your.Endpoint do
use GRPC.Endpoint
intercept GRPC.Server.Interceptors.CORS
end
defmodule Your.Endpoint do
use GRPC.Endpoint
intercept GRPC.Server.Interceptors.CORS, allow_origin: "some.origin"
end
defmodule Your.Endpoint do
use GRPC.Endpoint
def allow_origin(req, stream), do: "calculated.origin"
intercept GRPC.Server.Interceptors.CORS, allow: &Your.Endpoint.allow_origin/2
end