Skip to content

Commit

Permalink
Handle a 404/infinite redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
themisterholliday authored and wesbos committed Dec 7, 2023
1 parent ea66264 commit fe3af19
Showing 1 changed file with 6 additions and 1 deletion.
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

1 comment on commit fe3af19

@vercel
Copy link

@vercel vercel bot commented on fe3af19 Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

syntax-website – ./

syntax-website-git-main-syntax.vercel.app
www.syntax.fm
syntax-website-syntax.vercel.app
beta.syntax.fm
syntax.fm

Please sign in to comment.