@fastify/reply-from 8.4.2 → 8.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -74,7 +74,7 @@ const fastifyReplyFrom = fp(function from (fastify, opts, next) {
74
74
  }
75
75
 
76
76
  const sourceHttp2 = req.httpVersionMajor === 2
77
- const headers = sourceHttp2 ? filterPseudoHeaders(req.headers) : req.headers
77
+ const headers = sourceHttp2 ? filterPseudoHeaders(req.headers) : { ...req.headers }
78
78
  headers.host = url.host
79
79
  const qs = getQueryString(url.search, req.url, opts)
80
80
  let body = ''
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastify/reply-from",
3
- "version": "8.4.2",
3
+ "version": "8.4.3",
4
4
  "description": "forward your HTTP request to another server, for fastify",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -18,7 +18,13 @@ test('hostname', async (t) => {
18
18
  })
19
19
 
20
20
  instance.get('*', (request, reply) => {
21
- reply.from()
21
+ reply.from(null, {
22
+ rewriteRequestHeaders: (originalReq, headers) => {
23
+ t.equal(headers.host, 'httpbin.org')
24
+ t.equal(originalReq.headers.host, `localhost:${instance.server.address().port}`)
25
+ return headers
26
+ }
27
+ })
22
28
  })
23
29
 
24
30
  instance.register(From, {