simple nodejs middleware acting as a grpc-web gateway
Intall grpc-web-middleware with npm registry
$ npm install grpc-web-middleware
const grpcWebMiddleware = require('grpc-web-middleware')
grpcServerUrl
- The grpc server base urlprefix
- add a path prefix to handle grpc web request
Returns async function (req, res, next)
const express = require('express')
const expressApp = express()
const expressCors = require('cors')
const grpcWebMiddleware = require('grpc-web-middleware')
expressApp.use(expressCors())
expressApp.use(grpcWebMiddleware('http://localhost:6565'))
const Koa = require('koa')
const koaApp = new Koa()
const koaCors = require('@koa/cors')
const grpcWebMiddleware = require('grpc-web-middleware')
koaApp.use(koaCors())
koaApp.use(async (ctx,next) => grpcWebMiddleware('http://localhost:6565')(ctx.req,ctx.res,next))