-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I had an issue to connect to a python grpc server as the te: trailers header was missing.
The TE request header specifies the transfer encodings the user agent is willing to accept
As gRPC uses trailers, this needs to be set by the proxy to trailers
The following fixed the issue for me:
const app = connect();
const corsOptions = {
exposedHeaders: 'grpc-status,grpc-message',
methods: 'POST',
credentials: true,
};;
app.use((req, res, next) => {
req.headers['te'] = 'trailers'; // <--- pass necessary header
next();
})
app.use(cors(corsOptions));
app.use(grpcWeb(`http://0.0.0.0:${sourcePort}`));
return app.listen(destPort);essentially you could either add this middleware or provide users an ability to add preceding middleware by adjusting the proxy function:
const proxy = ({ target, origin, headers, middlewares } = {}) => {
const app = connect();
const corsOptions = getCorsOptions({ origin, headers });
(middlewares || []).forEach(middleware => {
app.use(middleware)
});
app.use(cors(corsOptions));
app.use(grpcWeb(target));
return app;
};I am willing to provide a PR for either
Metadata
Metadata
Assignees
Labels
No labels