-
Notifications
You must be signed in to change notification settings - Fork 10
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
When the request being proxied has multiple consecutive forward slashes, the proxy seems to break and cut off the rest of the URL.
For example, given the following backend server:
// server.js
const express = require('express')
let port = 3004
const app = express()
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.get('/test', (req, res) => {
res.send('Test Page!')
})
const server = app.listen(port, () => {
console.log(`Server listening on port ${port}`)
})And the following proxy usage:
// proxy.js
const http = require('http')
const httpProxy = require('http-proxy-3')
const proxy = httpProxy.createProxyServer({})
proxy.on('error', (err, req, res) => {
console.error('Proxy error:', err)
res.end('Something went wrong.')
})
const server = http.createServer((req, res) => {
const target = 'http://localhost:3004'
proxy.web(req, res, { target })
})
const port = 3005
server.listen(port, () => {
console.log(`Proxy server listening on port ${port}`)
})When I visit http://localhost:3005/test, I get the Test Page! response as expected. But when I visit http://localhost:3005//test (double forward slash //), it returns the Hello World! response (almost like like the //test part of the request URL was cut off, not sure if that's what's actually happening).
This doesn't happen with the latest (2018) version of the old http-proxy module, so that might be a clue.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working