Skip to content

Conversation

@mrmeku
Copy link

@mrmeku mrmeku commented Sep 26, 2024

Motivation

I've not had any luck using the recommended ways to enable custom CORS for GRPC-web using the recommended mechanisms.

Solution

This helper method is a much easier escape hatch for custom CORS layering. Instead of calling tonic_web::enable(service) which uses a default CORS layer you instead call tonic_web::enable_with_cors(service, cors_layer) with your own cors layer.

Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable.

@tottoto tottoto self-requested a review September 27, 2024 10:32
@tottoto
Copy link
Collaborator

tottoto commented Sep 27, 2024

For the future breaking change, considering making tower and tower-http crates internal dependencies to make tonic project less impactful against the updates of the dependencies. Can the config be made to be tower_layer::Layer instead of tower_http::cors::CorsLayer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants