dev-tunnels icon indicating copy to clipboard operation
dev-tunnels copied to clipboard

Devtunnel rewrites `localhost` location headers

Open Jafferwaffer opened this issue 6 months ago • 5 comments
trafficstars

Summary

When a server behind devtunnel sends an HTTP redirect to http://localhost:3000/some-url, devtunnel rewrites the Location header to something like:

Location: https://mytunnel.devtunnels.ms:3000/some-url

This breaks the redirect if port 3000 is not forwarded.

In my express server (which is being port forwarded) I am calling res.redirect('http://localhost:3000/some-url') but in the browser the location header is being rewritten as described above.

Steps to Reproduce

  1. Start a devtunnel on a port other than 3000.

  2. Serve a backend on that port that does:

    res.redirect('http://localhost:3000/some-url');
    
  3. Visit the devtunnel URL and trigger the redirect.

  4. The browser is redirected to https://<your-tunnel>:3000/some-url and fails to load.

Expected Behavior

Redirects to localhost should remain unchanged

Jafferwaffer avatar May 08 '25 16:05 Jafferwaffer