-
I have implemented a global URl check, but I want to stop running the sequence at a specific point and return the page. Is it possible? const redirects = async ({ event, resolve }) => {
const session = await event.locals.getSession()
if (!session) {
console.log(event.url.pathname)
const allowed_urls = ['/signin', '/unauthorized', '/', '/api']
if (allowed_urls.includes(event.url.pathname)) {
return await resolve() // <---- here I want to stop the sequesnce
}
throw redirect(303, '/signin')
}
return await resolve(event) // must handle api auth here
}
export const handle = sequence(auth, redirects, locals, authorization, logging) |
Beta Was this translation helpful? Give feedback.
Answered by
kyllerss
Mar 9, 2024
Replies: 1 comment
-
Not that I am aware of. If you want to skip elements in the sequence, then I would suggest you add some flag to the locals parameter that each sequence function can use to short-circuit their involvement. Also you don't need the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
alpap
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not that I am aware of. If you want to skip elements in the sequence, then I would suggest you add some flag to the locals parameter that each sequence function can use to short-circuit their involvement. Also you don't need the
throw
in the latest SvelteKit.