Comments (5)
What was the error? How should I reproduce it. I can interact with grpc-mate by browser with no problem.
from grpc-mate.
Create simple http server on same host, and type fetch('http://127.0.0.1:6600/actuator/services')
Error will be something like this
Access to fetch at 'http://127.0.0.1:6600/actuator/services' from origin 'http://127.0.0.1:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Having option to set Access-Control-Allow-Origin: *
will be nice
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
from grpc-mate.
I see. So you are requesting /actuator/services
using JavaScript, probably from a web UI running on other origin. It's not supported yet, but I think I can add it as an option. Is it needed for /v1/..
endpoints that are proxied to the backend gRPC server?
from grpc-mate.
There is a plan to add Web UI support: #8
Hopefully when it's done folks don't have to enable Access-Control headers and build a web UI theirselves. But for now, let me add an ACCESS_CONTROL_ALLOW_ORIGIN
env option to set the response header.
from grpc-mate.
I'm building some UI for generating documentation and sending requests (similar to openapi)
The challenge so far to get all proto details because grpc.reflection.v1alpha.ServerReflection
uses bi-directional streaming, which is not supported by grpc-mate
Btw any plans to support multiple backends?
As workaround I built grpc service to serve all protos as json
syntax = "proto3";
package internal;
option go_package = "protos";
service DescriptorServer { // after service
rpc getAll(DescriptorsRequest) returns (DescriptorsResponse) {} // ta ta ta
}
message DescriptorsRequest {
}
message DescriptorsResponse {
repeated string file = 1; // just one
}
go server
import (
"context"
pb "grpc-reflector/protos"
"github.com/gogo/protobuf/jsonpb"
log "github.com/sirupsen/logrus"
)
type DescriptorServer struct {
pb.UnimplementedDescriptorServerServer
}
// be careful with output, it may break your terminal
func (s *DescriptorServer) GetAll(ctx context.Context, in *pb.DescriptorsRequest) (*pb.DescriptorsResponse, error) {
all := []string{}
m := jsonpb.Marshaler{}
for _, descriptor := range CompiledProtos {
compiled, err := m.MarshalToString(descriptor)
if err == nil {
all = append(all, compiled)
} else {
log.Errorf("Can not compile %v", err)
}
}
return &pb.DescriptorsResponse{File: all}, nil
}
It serve protos encoded as json string, in this way I don't need to do any protobuf decoding in JS
Will share some preview when it's usable
from grpc-mate.
Related Issues (10)
- Unable to discover service
- TLS handshake errors (gRPC requires TLS) HOT 1
- Provide public docker image, support install and run using docker
- Make it easy to deploy in Kubernetes cluster
- Better error response when backend gRPC server does not reflection
- Support streaming calls
- Support filtering results from /actuator/services endpoint
- Add web GUI support
- Support gRPC HealthCheck
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-mate.