Skip to content

Conversation

Corvince
Copy link

@Corvince Corvince commented Oct 6, 2025

This is a first step towards http2 support (#2 ).

This PR allows incoming http2 requests towards the proxy. This means the proxy server can accept http2 requests, but forwards them as http1 requests towards the target server.

The primary motivation and use case for this PR is that currently vite falls back to http1, when proxy is set, because the proxy server can't handle http2 requests (see vitejs/vite#4184). With this PR, vite can send its own responses as http2 and forward http2 requests to the proxy server. The proxy server forwards the request as http1, but answers the http2 request. I tested this manually.

For full http2 support, the proxy server should forward the request as http2, if possible, but this will require a much larger effort, because the https client currently used can't make h2 requests and the http2 client can't make http1 requests. So we would have to either probe the target server to see if it supports h2 requests and make a http2 connection, for which the API would be slightly different, or evaluate the use of undicis fetch, which can make h2 requests and fall back to http1 transparently. But both approaches are outside the scope of this PR.

@williamstein williamstein merged commit 8f2a15c into sagemathinc:main Oct 8, 2025
3 checks passed
@williamstein
Copy link
Contributor

Thanks! Merged and published as [email protected]

@williamstein williamstein mentioned this pull request Oct 10, 2025
@Corvince
Copy link
Author

Thanks for the merge!

@sapphi-red Do you think this will suffice for vite to support proxy and https at the same time?

@sapphi-red
Copy link
Contributor

Yes! I'll reopen your PR.

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.

3 participants