diff --git a/.changeset/five-turtles-rhyme.md b/.changeset/five-turtles-rhyme.md new file mode 100644 index 000000000000..a7095d115b91 --- /dev/null +++ b/.changeset/five-turtles-rhyme.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +[fix] correctly populate `event.url.host` in dev mode when using `--https` diff --git a/packages/kit/src/core/dev/plugin.js b/packages/kit/src/core/dev/plugin.js index 9a05216b9ba1..d493af9c9a3e 100644 --- a/packages/kit/src/core/dev/plugin.js +++ b/packages/kit/src/core/dev/plugin.js @@ -197,7 +197,9 @@ export async function create_plugin(config, cwd) { try { if (!req.url || !req.method) throw new Error('Incomplete request'); - const base = `${vite.config.server.https ? 'https' : 'http'}://${req.headers.host}`; + const base = `${vite.config.server.https ? 'https' : 'http'}://${ + req.headers[':authority'] || req.headers.host + }`; const decoded = decodeURI(new URL(base + req.url).pathname);