use tonic_web::GrpcWebLayer;
use tower_http::cors::CorsLayer;
...
let cors_layer = CorsLayer::new(); // add whatever origins, methods, headers
Server::builder()
// GrpcWeb is over http1 so we must enable it.
.accept_http1(true)
.layer(cors_layer)
.layer(GrpcWebLayer::new())
.add_service(greeter)
.serve(addr)
.await?;
And when it tries to compile I get this:
.serve(addr)
| ^^^^^ the trait `Service<http::request::Request<tonic::transport::Body>>` is not implemented for `Cors<GrpcWebService<Routes>>`
|
= help: the trait `Service<http::Request<ReqBody>>` is implemented for `Cors<S>`
I didn't find a workaround for this. I would appreciate any advice/help.
Bug Report
Version
0.5.0
Platform
Windows / Linux
Crates
tonic = "0.10.2" tonic-web = "0.10.2" tower-http = { version = "0.5.0", features = ["cors"] }
Description
I was playing around with the code from https://github.com/hyperium/tonic/blob/master/examples/src/grpc-web/server.rs. I added a cors layer and grpc web layer with sample code given at https://docs.rs/tower-http/0.5.0/tower_http/cors/struct.CorsLayer.html.
And when it tries to compile I get this:
I didn't find a workaround for this. I would appreciate any advice/help.