grpc / grpc/grpc-rust

cors issue

Open
#1,636 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
12.5k
Forks
1.3k
Avg merge
4d 7h
Merged PRs (30d)
24

Description

## Bug Report

### Version

```
├── tonic v0.11.0
├── tonic-web v0.11.0
│ ├── tonic v0.11.0 (*)
└── tonic-build v0.11.0
```

### Platform

Darwin mbp-1.home 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:31:10 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6031 arm64

### Description

I tried this code:

```rust
let server = HealthServer { addr };

let svc = pb::health_server::HealthServer::with_interceptor(server, check_auth);

let cors = CorsLayer::new()
.allow_headers(Any)
.allow_methods([Method::GET, Method::POST])
.allow_origin(Any);

let serve = Server::builder()
.trace_fn(|_| tracing::info_span!("health_server"))
.accept_http1(true)
.layer(cors)
.layer(GrpcWebLayer::new())
.add_service(svc)
.serve(addr);
```

I expected to see this happen: should build

Instead, this happened:
Screenshot 2024-02-20 at 13 27 22

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.