Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

undici Pool not updated when using "base" option under Proxy function #56

Open
2 tasks done
Verttigo28 opened this issue Dec 10, 2021 · 0 comments
Open
2 tasks done

Comments

@Verttigo28
Copy link

Verttigo28 commented Dec 10, 2021

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

3.24.1

Plugin version

2.1.0

Node.js version

16.8.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

Windows 10 21H1

Description

If you set a base option to the Proxy function, the header "Location" will not be rewrite because of the Undici Pool not updated.

At the start of the plugin, we provide a base option, this option will provide the base URL for the Undici Pool creation under the "buildRequest" function in request.js

So if you have "http://google.com" as your default base option and under the Proxy function you have "http://127.0.0.1:3001" the location header will be "https://google.com/3001", so the request will "fail".

Steps to Reproduce

const { proxy } = require('../index')({ base: 'https://google.com', undici: { connections: 100, pipelining: 10 } }) const service = require('restana')() service.all('/*', (req, res) => proxy(req, res, req.url, { base: 'http://127.0.0.1:3001', rewriteRequestHeaders (req, headers) { delete headers.connection return headers } })) service.start(3000)

Expected Behavior

The request should go trough with the location header set by the base option under the Proxy function.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant