Giter VIP home page Giter VIP logo

Comments (5)

mwitkow avatar mwitkow commented on July 29, 2024

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.

sulliwane avatar sulliwane commented on July 29, 2024

Looking at the chrome dev-tools network tab, this is the preflight request (Request Method:OPTIONS) which is actually failing with 500.
screenshot from 2017-04-11 16-12-41

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.

sulliwane avatar sulliwane commented on July 29, 2024

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.

sulliwane avatar sulliwane commented on July 29, 2024

Oops...I just see that this behaviour is actually implemented in the wrapper.go. My bad!

from grpc-web.

sulliwane avatar sulliwane commented on July 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.