diff --git a/packages/kit/src/exports/node/index.js b/packages/kit/src/exports/node/index.js index 9b209bd49064..3e5930575f30 100644 --- a/packages/kit/src/exports/node/index.js +++ b/packages/kit/src/exports/node/index.js @@ -94,7 +94,8 @@ function get_raw_body(req, body_size_limit) { /** @type {import('@sveltejs/kit/node').getRequest} */ export async function getRequest({ request, base, bodySizeLimit }) { - return new Request(base + request.url, { + // @ts-expect-error - the request may be a connect request + return new Request(base + (request.originalUrl || request.url), { method: request.method, headers: /** @type {Record} */ (request.headers), body: get_raw_body(request, bodySizeLimit) diff --git a/packages/kit/src/exports/vite/dev/index.js b/packages/kit/src/exports/vite/dev/index.js index e8dc10837eb4..eccd7c98f3f7 100644 --- a/packages/kit/src/exports/vite/dev/index.js +++ b/packages/kit/src/exports/vite/dev/index.js @@ -258,7 +258,7 @@ export async function dev(vite, vite_config, svelte_config) { req.headers[':authority'] || req.headers.host }`; - const decoded = decodeURI(new URL(base + req.url).pathname); + const decoded = decodeURI(new URL(base + req.originalUrl).pathname); if (decoded.startsWith(assets)) { const pathname = decoded.slice(assets.length); @@ -295,7 +295,7 @@ export async function dev(vite, vite_config, svelte_config) { req.headers[':authority'] || req.headers.host }`; - const decoded = decodeURI(new URL(base + req.url).pathname); + const decoded = decodeURI(new URL(base + req.originalUrl).pathname); const file = posixify(path.resolve(decoded.slice(1))); const is_file = fs.existsSync(file) && !fs.statSync(file).isDirectory(); const allowed = @@ -311,7 +311,7 @@ export async function dev(vite, vite_config, svelte_config) { if (!decoded.startsWith(svelte_config.kit.paths.base)) { return not_found( res, - `Not found (did you mean ${svelte_config.kit.paths.base + req.url}?)` + `Not found (did you mean ${svelte_config.kit.paths.base + req.originalUrl}?)` ); }