FG
📡 Networking

Some sites break because of req.url being absolute

Freshover 12 years ago
Mar 14, 20260 views
Confidence Score86%
86%

Problem

According to the HTTP standard, a request's URI (the second field in the first line of an HTTP request, after the verb, and which gets into req.url) may be relative or absolute. A request to a proxy must always have an absolute URI, and indeed when we receive a request, req.url is always absolute. We just forward the request in proxyRequest and copy the URI into the new request. The receiving end of our new request will in turn get an absolute URI. This behaviour, however standard, is breaking some sites which naively expect the path to be relative to the hostname (starting with a "/"). They are wrong, but still node-http-proxy could be "fixed" so as to not break this assumption of theirs. By placing "req.url = req.url.replace(/._?:\/\/._?\//, '/')" (an ugly regexp, granted) before calling proxyRequest I was able to conform to the naiveté of Wordpress and other stuff which is out there being used and does not implement the standard. Thanks for building this nice, flexible proxy.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Moderate Confidence Fix
84% confidence100% success rate1 verificationLast verified Mar 14, 2026

Solution: Some sites break because of req.url being absolute

Low Risk

Here is my changeset to my front-end dev tool using node-http-proxy which fixes this assumption. https://github.com/fabiosantoscode/magicProxy/commit/d8118e37532bc479e71a806b8f1e2fcc9d8763db

84

Trust Score

1 verification

100% success
  1. 1

    Here is my changeset to my front-end dev tool using node-http-proxy which fixes

    Here is my changeset to my front-end dev tool using node-http-proxy which fixes this assumption.

  2. 2

    https://github.com/fabiosantoscode/magicProxy/commit/d8118e37532bc479e71a806b8f1

    https://github.com/fabiosantoscode/magicProxy/commit/d8118e37532bc479e71a806b8f1e2fcc9d8763db

Validation

Resolved in http-party/node-http-proxy GitHub issue #529. Community reactions: 0 upvotes.

Verification Summary

Worked: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

proxyhttpnode.js