Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/unlucky-walls-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: when using `@vitejs/plugin-basic-ssl`, set a no-op proxy config to downgrade from HTTP/2 to TLS since `undici` does not yet enable HTTP/2 by default
16 changes: 16 additions & 0 deletions packages/kit/src/exports/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,22 @@ async function kit({ svelte_config }) {
* Stores the final config.
*/
configResolved(config) {
// we search for this plugin by name because we can't detect it
// since it doesn't directly modify the https config unlike the mkcert plugin
const vite_basic_ssl = config.plugins.find(({ name }) => name === 'vite:basic-ssl');

// by default, when enabling HTTPS in Vite, it also enables HTTP/2
// however, undici has not yet enabled HTTP/2 by default: https://github.com/nodejs/undici/issues/2750
// we set a no-op proxy config to force Vite to downgrade to TLS-only
// see https://vitejs.dev/config/#server-https
if ((config.server.https || vite_basic_ssl) && !config.server.proxy) {
config.server.proxy = {};
}

if ((config.preview.https || vite_basic_ssl) && !config.preview.proxy) {
config.preview.proxy = {};
}

vite_config = config;
}
};
Expand Down
Loading