I am using NextJS to build my web application with https://github.com/improbable-eng/grpc-web for communication between backend and frontend.
The following React element uses grpc.invoke
to communicate with GRPC backend service:
export default function Index({user}: OverviewProps) {
useEffect(() => {
grpc.invoke(RepoService.ListRepos, {
host: "http://localhost:9000",
request: listReq,
onMessage: (msg) => {
console.log(msg);
},
onEnd:(code:grpc.Code,msg:string | undefined | number, trailers: grpc.Metadata)=>{
console.log(code);
if(code == grpc.Code.OK){
console.log("Worked")
}else{
console.log("Not Working")
}
},
debug: true
})
}, [])
return wrapWithLayout(
<p>Hi {user.nickname}</p>
);
}
The backend service is secured with TLS. On the client-side, I have to load somehow the certificate into the client. The question is, how to load the certificate into the client-side that it can communicate with the backend service?