Skip to content

Commit

Permalink
fix: only set 404 status on SSR (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Aug 10, 2022
1 parent 60e7c1f commit 18b6064
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions pages/[...slug].vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, useContent, useHead, useTheme } from '#imports'
import { computed, useContent, useHead, useRequestEvent, useTheme } from '#imports'
definePageMeta({
/* Layout transitions creates layout shifts with defaults */
Expand All @@ -10,14 +10,10 @@ definePageMeta({
const { page } = useContent()
const theme = useTheme()
// Page not found
if (!page.value) {
throwError(
createError({
statusCode: 404,
statusMessage: `Page not found: ${useRoute().path}`,
}),
)
// Page not found, set correct status code on SSR
if (!page.value && process.server) {
const event = useRequestEvent()
event.res.statusCode = 404
}
const cover = computed(() => {
Expand Down

0 comments on commit 18b6064

Please sign in to comment.