Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle a 404/infinite redirect #1426

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/routes/(site)/shows/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export const load: PageServerLoad = async function ({ locals, url, setHeaders })
console.log(`No shows on this page, redirecting to page 1`);
const params = new URLSearchParams(url.searchParams);
params.delete('page');
throw redirect(302, `/shows?${params.toString()}`);
const params_string = params.toString();
if (params_string.length <= 0) {
console.log(`No params for this page redirect. Abort to the homepage!`);
throw redirect(302, `/`);
}
throw redirect(302, `/shows?${params_string}`);
}

return {
Expand Down
Loading