Using gRPC-web as the communication method between front-end and back-end, this project provides two solutions:
1. gRPC-Web Solution
Important
grpc-web is a client side library. XHLHttpRequest is not supported by Next.js server side rendering.
┌──────────────┐ ┌────────────────┐ ┌───────────────┐
│ Browser ├────►│ gRPC Proxy ├────►│ gRPC Server │
└──────────────┘ └────────────────┘ └───────────────┘
2. Server Side Solution
If you want to use Server Side Rendering, you need to make gRPC requests directly from the Next.js server to the RPC server.
┌──────────────┐ ┌────────────────┐ ┌───────────────┐
│ Browser ├────►│ Next.js Server ├────►│ gRPC Server │
└──────────────┘ └────────────────┘ └───────────────┘
The two approaches above can be used in combination, depending on the actual situation.
Command line tools:
install requirement
make install
generate protobuf
make buf
if you want to know more about details for buf build , see Makefile
If you like this project, please consider supporting me for coffee ☕️