Closed AnthonySendra closed 3 years ago
More context:
We call the callback with only two parameters here: https://github.com/nestjs/nest/blob/master/packages/microservices/server/server-grpc.ts#L136
In my case, this callback comes from here: https://github.com/grpc/grpc-node/blob/master/packages/grpc-native-core/src/server.js#L590
And call the function sendUnaryResponse
defined here:
https://github.com/grpc/grpc-node/blob/master/packages/grpc-native-core/src/server.js#L83
This function take metadata
in argument but we don't pass it in the arguments of the callback
.
I tried to update the function like:
createUnaryServiceMethod(methodHandler) {
return async (call, callback) => {
console.log('createUnaryServiceMethod', callback);
const handler = methodHandler(call.request, call.metadata);
this.transformToObservable(await handler).subscribe(
data => {
if (data.response && data.metadata) {
callback(null, data.response, data.metadata);
} else {
callback(null, data);
}
},
err => callback(err),
);
};
}
But now I have an error in my browser. The metadata is not sent in the headers but in body
@kamilmysliwiec how about this issue...? Can you help me. I need send metadata response to client. I need to attach version of application service. I need attach to anywhere but not in body data of gRPC.
See https://github.com/nestjs/nest/pull/5143 for instructions. This PR was merged and released as 7.5.0
I'm submitting a...
Current behavior
When I create a microservice GRPC server with NestJS, I can't send metadata in my response.
Expected behavior
I want to be able to send headers to my client.
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
I need to find a way to send the header
Set-Cookie
for authenticationEnvironment