Skip to content

Commit 2942aa8

Browse files
author
Aleksandr Usenko
committed
Fix nested upstream url processing
1 parent 196eab9 commit 2942aa8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

proxy/upstream.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ function getAgent(isHTTPS, hostname) {
185185

186186
export function forwardRequest(clientReq, body, signal) {
187187
return new Promise((resolve, reject) => {
188-
const upstreamUrl = new URL(clientReq.url, config.upstream);
188+
const base = config.upstream.endsWith('/') ? config.upstream.slice(0, -1) : config.upstream;
189+
const relative = clientReq.url.startsWith('/') ? clientReq.url : '/' + clientReq.url;
190+
const upstreamUrl = new URL(base + relative);
189191

190192
const headers = buildUpstreamHeaders(clientReq.headers, upstreamUrl.hostname);
191193
if (body) {

0 commit comments

Comments
 (0)