Closed achapmandc2 closed 11 months ago
Issue resolved, needed to wrap the get call in a try/catch and redirect manually to the 404 page on error.
const { data } = await storyblokApi.get(
`cdn/stories/${slug === undefined ? 'home' : slug}`,
{
version: isPreview() ? 'draft' : 'published',
}
)
content = data.story.content
metadata = data.story.content.metadata
}
catch {
return Astro.redirect('/404')
}
When I navigate to a slug that does not exist I expect my 404.astro page to load.
I have created a 404.astro within my pages folder, alongside [...slug].astro
This is the code for my [...slug].astro
Expected Behavior
When a slug that does not exist is accessed I expect my 404.astro page to render
Current Behavior
In Production (Cloudflare) : Browser based 500 error In dev (localhost): I get the vite error page with the 404 error