Skip to content

fix: support rack-proxy 1.0 (close #622) - #623

Merged
ElMassimo merged 1 commit into
mainfrom
fix/rack-proxy-1
Aug 28, 2026
Merged

fix: support rack-proxy 1.0 (close #622)#623
ElMassimo merged 1 commit into
mainfrom
fix/rack-proxy-1

Conversation

@ElMassimo

@ElMassimo ElMassimo commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Description 📖

This pull request makes ViteRuby::DevServerProxy compatible with rack-proxy 1.0, so proxied asset requests during development no longer fail with 502 Bad Gateway. Closes #622.

Background 📜

This was happening because #619 relaxed the dependency to rack-proxy >= 0.6.1, which lets bundler resolve rack-proxy 1.0. rack-proxy 1.0 refuses to derive a backend from the client-controlled Host header unless you explicitly opt in (an SSRF/open-proxy guard). DevServerProxy selected the Vite backend precisely by rewriting the Host header, so on rack-proxy 1.0 every proxied request returned [502, {}, []]:

rack-proxy: refusing Host-derived backend "localhost" (no :backend configured; pass allow_dynamic_backend: true to opt in)

The Fix 🔨

By changing forward_to_vite_dev_server to set an explicit, config-derived backend on the request env rather than relying on the Host header:

env["rack.backend"] = URI(config.origin)

@ElMassimo
ElMassimo merged commit 3486248 into main Aug 28, 2026
30 checks passed
@ElMassimo
ElMassimo deleted the fix/rack-proxy-1 branch August 28, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dev server proxy returns 502 on rack-proxy 1.0 (Host-derived backend refused)

1 participant