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

fastify-http-proxy

Package Overview
Dependencies
Maintainers
8
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-http-proxy - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

1

index.d.ts

@@ -26,2 +26,3 @@ /// <reference types="node" />

http2?: boolean;
proxyPayloads?: boolean;
preHandler?: (

@@ -28,0 +29,0 @@ request: FastifyRequest<

6

index.js

@@ -25,4 +25,6 @@ 'use strict'

fastify.addContentTypeParser('application/json', bodyParser)
fastify.addContentTypeParser('*', bodyParser)
if (opts.proxyPayloads !== false) {
fastify.addContentTypeParser('application/json', bodyParser)
fastify.addContentTypeParser('*', bodyParser)
}

@@ -29,0 +31,0 @@ function rewriteHeaders (headers) {

{
"name": "fastify-http-proxy",
"version": "3.0.0",
"version": "3.1.0",
"description": "proxy http requests, for Fastify",

@@ -33,3 +33,3 @@ "main": "index.js",

"fastify": "^2.0.0",
"got": "^10.0.0",
"got": "^10.6.0",
"http-errors": "^1.7.1",

@@ -36,0 +36,0 @@ "http-proxy": "^1.17.0",

@@ -97,2 +97,15 @@ # fastify-http-proxy

### proxyPayloads
When this option is `false`, you will be able to access the body but it will also disable direct pass through of the payload. As a result, it is left up to the implementation to properly parse and proxy the payload correctly.
For example, if you are expecting a payload of type `application/xml`, then you would have to add a parser for it like so:
```javascript
fastify.addContentTypeParser('application/xml', (req, done) => {
const parsedBody = parsingCode(req)
done(null, parsedBody)
})
```
### config

@@ -99,0 +112,0 @@

@@ -114,2 +114,26 @@ 'use strict'

test('skip proxying the incoming payload', async t => {
const server = Fastify()
server.register(proxy, {
upstream: `http://localhost:${origin.server.address().port}`,
proxyPayloads: false,
preHandler (request, reply, next) {
t.deepEqual(request.body, { hello: 'world' })
next()
}
})
await server.listen(0)
t.tearDown(server.close.bind(server))
await got(
`http://localhost:${server.server.address().port}/this-has-data`,
{
method: 'POST',
json: { hello: 'world' },
responseType: 'json'
}
)
})
test('preHandler', async t => {

@@ -116,0 +140,0 @@ const server = Fastify()

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