Comments (5)
Well, the typical way of debugging Go programs is... printf ;)
You can easily tweak the grpcwebproxy handling method, it's here:
https://github.com/improbable-eng/grpc-web/blob/master/go/grpcwebproxy/main.go#L77
fmt.Printf("got request: %v", req)
should do the trick.
from grpc-web.
Looking at the chrome dev-tools network tab, this is the preflight request (Request Method:OPTIONS
) which is actually failing with 500.
As the preflight request do not have the content-type
header field, the grpcwebproxy method IsGrpcWebRequest
returns false
.
I believe the preflight request should not be tested with IsGrpcWebRequest
method....What do you think?
from grpc-web.
this is from the grpc-nginx-gateway
conf:
location / {
grpc_pass localhost:60052;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Transfer-En$
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
If request method is OPTIONS, then gateway return 204.
from grpc-web.
Oops...I just see that this behaviour is actually implemented in the wrapper.go
. My bad!
from grpc-web.
I solved the preflight problem by adding:
Handler: http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
resp.Header().Set("Access-Control-Allow-Origin", "*")
resp.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
resp.Header().Set("Access-Control-Allow-Headers", "Origin, Content-Type")
Even if there is a function responsible to check the origin, it returns true by default, but never set the Access-Control-Allow-Origin
. I'm probably doing it wrong, but it works now
from grpc-web.
Related Issues (20)
- Empty grpc-message header throws an error HOT 7
- grpcwebproxy websocket implementation fails on multiple subprotocols HOT 2
- Implement the http.RoundTripper interface? HOT 2
- Detach IsGrpcWebRequest and IsGrpcWebSocketRequest from WrappedGrpcServer HOT 2
- grpcwebproxy websocket connection fails with specific origin HOT 2
- QUIC and HTTP3 support HOT 1
- Status codes and error messages are displayed incorrectly on the angular client. HOT 4
- Golang Grpc Web Server UnaryInterceptor is not triggered by grpc-web Client HOT 1
- Get client stream method return HOT 3
- ReferenceError: self is not defined when trying to call a grpc-web function from a CLI/server application HOT 3
- grpcwebproxy - Help Proxying existing GRPC service HOT 1
- Add support of bufbuild/protobuf-es HOT 3
- Changing route to the root of the host HOT 1
- Lack of grpc Trailers-Only support in the wrapHandler function
- Is there any way to use Nginx or Envoy with this project? HOT 1
- Question: What is the status of `go/grpcwebproxy` project? HOT 3
- grpc-web: Importing as ESModule in Node HOT 1
- grpcwebproxy `--allowed_headers` param is case-sensitive for WebSocket
- Grpc client unexpected behavior HOT 1
- Project status
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grpc-web.