question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with cors after the last release 1.0.4

See original GitHub issue

alt text

golang app

func allowCors(w http.ResponseWriter, req *http.Request) {
	w.Header().Set("Access-Control-Allow-Origin", "http://localhost:3000")
	w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
	w.Header().Set("Access-Control-Expose-Headers", "grpc-status, grpc-message")
	w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, XMLHttpRequest, x-user-agent, x-grpc-web, grpc-status, grpc-message")
}

the problem only happens with chrome… the version that I’m using is Version 73.0.3683.75 (Official Build) (64-bit) It seems this new release sends this two extra headers "grpc-status, grpc-message" even though I have this specified in my golang above, this is still throwing this errors in my react app

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
maurodelazericommented, Apr 3, 2019

@BirknerAlex instead of wrapping the grpc server with http you can use tcp and connect to it using a proxy, for instance here is an example with envoy-proxy… it will solve the problem and I think would be a better solution

https://github.com/maurodelazeri/grpcweb/tree/master/envoy-proxy

2reactions
BirknerAlexcommented, Apr 3, 2019

Don’t know if it makes sense to re-open this issue but I got the same issue. After downgrading to version 1.0.3 everything works fine.

I’m using the server from here -> https://github.com/improbable-eng/grpc-web/tree/master/go/grpcweb

The thing is, both headers grpc-status and grpc-message are only included in the HTTP response header if a GRPC error returns. If a protobuf message will be returned both headers are missing.

Working request with error response:

OPTIONS:

Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type, X-Grpc-Web, X-User-Agent
Access-Control-Allow-Methods: POST
Access-Control-Allow-Origin: http://127.0.0.1:8080
Access-Control-Max-Age: 600
Content-Length: 0
Date: Wed, 03 Apr 2019 16:00:08 GMT
Vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers

POST:

Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://127.0.0.1:8080
Access-Control-Expose-Headers: Vary, Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Grpc-Status, Grpc-Message, Date, Content-Type
Content-Type: application/grpc-web-text
Grpc-Message: user has not been found
Grpc-Status: 5
Transfer-Encoding: chunked
Vary: Origin

Non working request with protobuf response:

OPTIONS:

Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type, X-Grpc-Web, X-User-Agent
Access-Control-Allow-Methods: POST
Access-Control-Allow-Origin: http://127.0.0.1:8080
Access-Control-Max-Age: 600
Content-Length: 0
Date: Wed, 03 Apr 2019 16:01:23 GMT
Vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers

POST:

Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://127.0.0.1:8080
Access-Control-Expose-Headers: Vary, Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Date, Content-Type
Content-Type: application/grpc-web-text
Transfer-Encoding: chunked
Vary: Origin

Not sure if its defined by GRPC if both headers are required or not but I think one of the project (client or server) does it in the wrong way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue in Enabling CORS for Web API 1, .net 4.0 - Stack Overflow
I found this simple solution by charanjit singh. It worked nicely especially if you are stuck with older visual studio 2010 , on...
Read more >
3 Ways to Fix the CORS Error — and How the Access-Control ...
Fix one: install the Allow-Control-Allow-Origin plugin. The quickest fix you can make is to install the moesif CORS extension .
Read more >
Microsoft.AspNetCore.Mvc.Cors 1.0.4 - NuGet
This package has at least one vulnerability with high severity. It may lead to specific problems in your project. Try updating the package...
Read more >
CORS error with Jira REST API on Cloud - Atlassian Community
For further explanation: The problem why we don't support CORS directly on your site host/domain is that we accept session based authentication on...
Read more >
Enabling Cross Origin Requests for a RESTful Web Service
The browser will fail the request if the CORS headers are missing from the response. To test the CORS behaviour, you need to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found