diff options
-rw-r--r-- | .changeset/tidy-peas-accept.md | 5 | ||||
-rw-r--r-- | packages/astro/src/core/preview/vite-plugin-astro-preview.ts | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/.changeset/tidy-peas-accept.md b/.changeset/tidy-peas-accept.md new file mode 100644 index 000000000..fa580f073 --- /dev/null +++ b/.changeset/tidy-peas-accept.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes preview server `trailingSlash` handling for request URLs with query strings diff --git a/packages/astro/src/core/preview/vite-plugin-astro-preview.ts b/packages/astro/src/core/preview/vite-plugin-astro-preview.ts index 9faabe29b..b07b88b7a 100644 --- a/packages/astro/src/core/preview/vite-plugin-astro-preview.ts +++ b/packages/astro/src/core/preview/vite-plugin-astro-preview.ts @@ -24,7 +24,8 @@ export function vitePluginAstroPreview(settings: AstroSettings): Plugin { return; } - const pathname = stripBase(req.url!, base); + const strippedPathname = stripBase(req.url!, base); + const pathname = new URL(strippedPathname, 'https://a.b').pathname const isRoot = pathname === '/'; // Validate trailingSlash |