From 109722caae92a14e9d993bb0335daf20ea6d10e8 Mon Sep 17 00:00:00 2001 From: yutak23 <79501292+yutak23@users.noreply.github.com> Date: Thu, 5 Sep 2024 22:10:42 +0900 Subject: [PATCH] fix: emulate `event.platform` even if route is undefined (#12513) * fix: in dev, emulate event.platform even if route is undefined * chore: add .changeset * Update .changeset/shiny-suns-scream.md Co-authored-by: Tee Ming * fix: suggest apply Co-authored-by: Tee Ming * fix: suggest apply Co-authored-by: Tee Ming * chore: format * Update .changeset/shiny-suns-scream.md --------- Co-authored-by: Tee Ming --- .changeset/shiny-suns-scream.md | 5 +++++ packages/kit/src/runtime/server/respond.js | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/shiny-suns-scream.md diff --git a/.changeset/shiny-suns-scream.md b/.changeset/shiny-suns-scream.md new file mode 100644 index 000000000000..46c039dd21d0 --- /dev/null +++ b/.changeset/shiny-suns-scream.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: emulate `event.platform` even when the route does not exist diff --git a/packages/kit/src/runtime/server/respond.js b/packages/kit/src/runtime/server/respond.js index 7ec768c1ad4d..f81f52ef2557 100644 --- a/packages/kit/src/runtime/server/respond.js +++ b/packages/kit/src/runtime/server/respond.js @@ -298,6 +298,11 @@ export async function respond(request, options, manifest, state) { event.platform = await state.emulator.platform({ config, prerender }); } } + } else if (state.emulator?.platform) { + event.platform = await state.emulator.platform({ + config: {}, + prerender: !!state.prerendering?.fallback + }); } const { cookies, new_cookies, get_cookie_header, set_internal } = get_cookies(