-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interceptor doesn't preserve HTTP method, causing CORS failures #911
Comments
I will have to dig in but shouldn't tonic-web be handling this aspect? |
Tonic-web does handle it, but only when the grpc service itself is called. Consider the following server definition. let router = Server::builder()
.layer(interceptor(my_interceptor_fn))
.add_service(tonic_web::enable(my_svc));
An alternative to modifying The input and output of |
I believe with #912 we can close this. |
Before the request is sent to an interceptor, the HTTP request is converted into a Tonic request and its body is removed. After the interceptor has transformed the Tonic request, the body is added back in, and it is converted back into an HTTP request. However, this last conversion assumes that the request will always be an HTTP2 POST.
Tonic-web handles preflight CORS requests (which have the HTTP OPTIONS method), but if there is an interceptor before the Tonic service, the request is changed from OPTIONS to POST before tonic-web sees it, and an incorrect response is sent, causing a CORS failure in the browser.
The text was updated successfully, but these errors were encountered: