Skip to content

Commit

Permalink
account for search params
Browse files Browse the repository at this point in the history
  • Loading branch information
eltigerchino committed Dec 3, 2023
1 parent 1a03065 commit 6cd4623
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/kit/src/exports/vite/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ export async function preview(vite, vite_config, svelte_config) {

vite.middlewares.use((req, res, next) => {
const original_url = /** @type {string} */ (req.url);
const { pathname } = new URL(original_url, 'http://dummy');
const { pathname, search } = new URL(original_url, 'http://dummy');

// if `paths.base === '/a/b/c`, then the root route is `/a/b/c/`,
// regardless of the `trailingSlash` route option
if (base.length > 1 && pathname === base) {
let location = base + '/';
if (search) location += search;
res.writeHead(307, {
location: base + '/'
location
});
res.end();
return;
Expand Down

0 comments on commit 6cd4623

Please sign in to comment.