Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@springernature/backend-proxy

Package Overview
Dependencies
Maintainers
12
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@springernature/backend-proxy - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

7

HISTORY.md
# History
## 2.2.0
_08/07/20_
- `backendHeaders` option added, in order to offer the ability to supplement
the outgoing HTTP response headers with some of the Backend response headers. ([morgaan](https://github.com/morgaan))
## 2.1.0

@@ -4,0 +11,0 @@ _19/06/20_

2

package.json
{
"name": "@springernature/backend-proxy",
"version": "2.1.0",
"version": "2.2.0",
"description": "Proxies frontend requests to a backend and can render the result",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -36,3 +36,4 @@ # backend-proxy

usePath: false,
interceptErrors: true
interceptErrors: true,
backendHeaders: ['set-cookie']
}), (req, res) => {

@@ -49,5 +50,6 @@ res.render('login', req.backendResponse);

| `requiredContentType` | Backend response content type thats required to allow interception and deserialization | string | `application/json` |
| `usePath` | Should the incoming HTTP request's path be apended to the `backend` URL | boolean | `true` |
| `usePath` | Should the incoming HTTP request's path be appended to the `backend` URL | boolean | `true` |
| `interceptErrors` | Should backend responses with HTTP 400 - 599 be intercepted and raised as express errors. If provided as a function, it takes the backendResponse as parameter and returns a boolean. This gives the frontend the flexibility to decided on a per-response status code basis. | undefined, boolean or function | `undefined` |
| `key` | The property on the request object that the backend response will be stored under. | string | `backendResponse` |
| `backendHeaders` | List of headers to copy from a Backend response to the outgoing client response (e.g. `Set-Cookie`...) | string[] | |

@@ -54,0 +56,0 @@ ### `renderBackendResponse(options)`

@@ -22,3 +22,3 @@ const http = require('http');

try {
// Supplement req with data from BE
// Supplement request with data from Backend
request[options.key] = JSON.parse(Buffer.concat(stringBody).toString('utf8'));

@@ -73,2 +73,8 @@ handled = true;

if (contentType === options.requiredContentType || contentType === `${options.requiredContentType}; charset=utf-8`) {
// Supplement response with headers from Backend, if needed
if (Array.isArray(options.backendHeaders) && backendResponse.headers) {
options.backendHeaders
.filter(header => backendResponse.headers[header])
.forEach(header => response.set(header, backendResponse.headers[header]));
}
tryReadData(options, backendResponse, request, next);

@@ -75,0 +81,0 @@ } else {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc