Socket
Socket
Sign inDemoInstall

@grpc-web/proxy

Package Overview
Dependencies
18
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @grpc-web/proxy

gRPC Web proxy for Node.js


Version published
Weekly downloads
583
decreased by-26.48%
Maintainers
1
Install size
440 kB
Created
Weekly downloads
 

Readme

Source

@grpc-web/proxy npm tests coverage

gRPC Web proxy for Node.js

For Express and Connect middleware, see @grpc-web/middleware

Installation

npm install @grpc-web/proxy

Usage

This is a standalone proxy server created using @grpc-web/middleware, connect and cors packages. It can be run directly from the command line:

npx @grpc-web/proxy --target http://localhost:9090 --listen 8080

or used as a library:

const proxy = require('@grpc-web/proxy');

proxy({ target: 'http://localhost:9090' }).listen(8080);

The address http://localhost:9090 refers to the gRPC server address to which gRPC Web requests are forwarded to and 8080 refers to the port on which the proxy server is running.

It can be run in the same process as the gRPC server:

// Proxy server
proxy({ target: 'http://localhost:9090' }).listen(8080);

// gRPC server
const server = new grpc.Server();
server.addProtoService(service, implementation);
server.bind('0.0.0.0:9090', credentials);
server.start();

It also accepts a custom function which can used for configuring the HTTP/2 connection to the gRPC server:

const http2 = require('node:http2');

proxy({
  target: () => {
    return http2.connect('http://localhost:9090');
  },
}).listen(8080);

Options

  • target: gRPC server address or a custom function that returns a HTTP/2 connection to the gRPC server. See @grpc-web/middleware.
  • origin: Configures the Access-Control-Allow-Origin CORS header. See origin option in cors.
  • headers: Configures the Access-Control-Expose-Headers CORS header. See exposedHeaders option in cors.

License

MIT

Keywords

FAQs

Last updated on 15 Apr 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc