DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

Why Two Proxies Can Make Every Page Return a 500

A CDN and origin proxy can contribute duplicate forwarding values that break URL construction in middleware. Trace each hop, verify trusted headers, and check downstream rewrites before changing the configured origin.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If every page starts returning HTTP 500 after a site is placed behind a CDN and a second proxy, inspect the forwarding headers reaching the application. In one reported Next.js and Auth.js v5 beta deployment, both proxy hops contributed https to X-Forwarded-Proto. Fetch exposed the repeated values as https, https; Auth.js then used that string to build a session URL, and URL parsing failed. Because the authentication wrapper ran on matched requests, the error affected routes even when they did not otherwise need session data.

How a repeated forwarding value can break URL construction

The failure described by Mahmut Gündüzalp followed a browser-to-CDN-to-origin-web-server-to-Node request path. The CDN set X-Forwarded-Proto: https, and the origin web server also added its own HTTPS value. Depending on proxy behavior, those values appeared as repeated header lines or as a comma-separated value.

As an Amazon Associate I earn from qualifying purchases.

In the reported build, the Fetch Headers object exposed repeated values as one comma-separated string. With no AUTH_URL configured, the Auth.js v5 beta path described in the case read x-forwarded-host and x-forwarded-proto, then used the scheme to construct an absolute URL. A single https produced an ordinary HTTPS URL; https, https did not. The attempted URL was effectively https, https://example.org, and new URL(...) threw TypeError: Invalid URL. The case author says these outcomes were re-measured against the deployed library build. Read the case study by Mahmut Gündüzalp.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The important point is not that every pair of proxies causes this exception. It is that middleware or a library may treat a multi-value forwarding header as one scheme or host, even though multiple hops can contribute values. The result depends on the proxy chain, header handling, and exact deployed library version.

Why the error reached routes that did not need a session

The application used the Auth.js auth() middleware wrapper to resolve a session for matched requests. In the reported configuration, URL construction happened inside that wrapper before the site’s own middleware logic. A thrown parsing error therefore interrupted requests to matched paths whether or not the eventual route itself needed session information.

The author reports that the local development machine did not reproduce the issue because it lacked the deployed proxy chain. That contrast is a useful clue: compare the request as it arrives at the application in production with the request reaching the app locally, rather than assuming the route code is responsible.

Rank #2

Trace the request from the application outward

  1. Capture the values at the application boundary. Log the received X-Forwarded-Proto and X-Forwarded-Host, including whether the server exposes repeated lines as a comma-joined value. Protect sensitive host and request data in logs.
  2. Map each proxy hop. Record which component sets, appends, preserves, or overwrites forwarding metadata. RFC 7239 permits successive proxies to add values using another field or a comma-separated value. RFC 7239: Forwarded HTTP Extension.
  3. Find where the application builds absolute URLs. Check authentication middleware, redirects, callbacks, and other code that assumes the forwarded scheme or host is a single value. Verify behavior against the version actually deployed.
  4. Check the trusted-proxy boundary. Determine whether the edge proxy overwrites client-supplied forwarding values or preserves them, and which upstream hops the application is configured to trust.
  5. Trace what happens after origin configuration changes. If an explicit public origin is introduced, inspect later redirects and rewrites that derive their target from the request URL.
  6. Correlate the application exception with proxy logs. Identify which component emitted the status before treating the status code as a diagnosis.

Why blindly taking the first or last value is unsafe

Do not treat “use the first value” or “use the last value” as a universal repair. Which entry is meaningful depends on which proxy is trusted, what each hop records, whether a client-provided value was overwritten, and the framework’s intended origin semantics. RFC 7239 warns that forwarded information can be altered by nodes along the path, including the client. Trust should come from a deliberately configured proxy boundary, not from the header’s name alone.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The RFC describes the standardized Forwarded header; the case concerns the commonly used X-Forwarded-* fields. Their exact parsing and proxy behavior can vary by implementation. Confirm the conventions used by the actual CDN, origin server, framework, and deployed library rather than assuming that all headers or proxy chains behave alike.

What the AUTH_URL workaround fixed—and what it broke

In the case report, setting AUTH_URL=https://example.org avoided the malformed session URL. It also caused the wrapper to rebuild the request using the public origin. A later i18n middleware generated a rewrite from req.url; with the public address in that URL, the rewrite went back through the CDN and looped.

This was a secondary failure in that deployment, not proof that an explicit origin always causes rewrite loops. Before adopting an explicit origin, follow the request through every downstream middleware that creates absolute redirects or rewrites. Establish whether those components need the internal origin, the public origin, or a path-only target.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Distinguish an application 500 from a proxy 502

HTTP 500 means the server encountered an unexpected condition; it does not identify which line of code or component failed. HTTP 502 means a gateway or proxy received an invalid response from an upstream server. Either status needs logs and request-path evidence to locate the cause. The definitions appear in the legacy HTTP/1.1 specification, RFC 2616; the code alone is not a diagnosis. RFC 2616: Hypertext Transfer Protocol — HTTP/1.1.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.