Skip to content

Commit

Permalink
refactor: tidy revalidate path
Browse files Browse the repository at this point in the history
  • Loading branch information
ob6160 committed May 29, 2022
1 parent b97e80f commit cc9b38b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/pages/api/loos/[id]/revalidate.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ export default async function handler(
const isMessageValid =
Object.keys(alertMessages).indexOf(message as string) > -1;

const finalMessage = isMessageValid ? message : 'generic_error';
const finalMessage = isMessageValid ? message : '';

try {
// Check that the user has a valid session before allowing revalidation.
// We might have a session on toiletmap.org.uk.
const { user } = getSession(req, res);
if (user) {
await res.unstable_revalidate(`/loos/${id}`);
return res.redirect(`/loos/${id}?message=${finalMessage}`);
}
return res.redirect(`/loos/${id}?message=${finalMessage}`);
} catch (err) {
Expand Down

1 comment on commit cc9b38b

@vercel
Copy link

@vercel vercel bot commented on cc9b38b May 29, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.