Package Exports
- nest-local-https-proxy
- nest-local-https-proxy/dist/lib/local-https-proxy.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nest-local-https-proxy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
A lightweight local HTTPS proxy library for Nest framework apps (Express or Fastify) 🔀
Description
A lightweight local HTTPS proxy library for Nest framework apps, supporting both Express and Fastify HTTP adapters, designed for use with self-signed SSL certificates.
⚠ Disclaimer
This library is intended only for use in local development, testing, and troubleshooting with self-signed SSL certificates. It is not recommended to use this in any production context or public-facing environment.
Always follow best practices when managing SSL certificates for any public-facing or production environment.
Self-signed SSL Certificates
See the following gist for info on creating self-signed SSL certificate PEM files using openssl:
Installation
$ npm i nest-local-https-proxyImplementation
Load your certificate and private key files into an HTTPS options (
SecureContextOptions) object.const certPath = './cert.pem'; const keyPath = './key.pem'; let httpsOptions: SecureContextOptions; // Confirm local certificate files exist if (fs.existsSync(certPath) && fs.existsSync(keyPath)) { httpsOptions = { cert: fs.readFileSync(certPath), key: fs.readFileSync(keyPath), }; } else { console.log('Failed to initalize HTTPS certificates for local SSL proxy'); }
Instatiate the
LocalHttpsProxyclass.Provide your
NestApplicationinstance, and the HTTPS options object.const httpsDevProxy = new LocalHttpsProxy(app, httpsOptions);
(Optional) Subscribe to events on
LocalHttpsProxyinstance.httpsDevProxy.on('listening', (httpsPort) => { console.log(`HTTPS listening on ${httpsPort}`); }); httpsDevProxy.on('error', (error) => { console.error(`HTTPS proxy error occurred: ${error.message}`); });
Start the proxy
httpsDevProxy.start(port);
Test
# unit tests
$ npm run test
# test coverage
$ npm run test:covLicense
The nest-local-https-proxy project is MIT licensed.