fast-proxy
fast-proxy copied to clipboard
undici Pool not updated when using "base" option under Proxy function
Prerequisites
- [X] I have written a descriptive issue title
- [X] 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.