You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to modify this code show a different page depending on the status code returned by the content query. In my case I have a server middleware that returns 403 if the user has no access to the content. How can I get the http status?
<script setup lang="ts">
import { useContent, useContentHead, useRequestEvent } from '#imports'
const { page, layout } = useContent()
// Page not found, set correct status code on SSR
if (!page.value && process.server) {
const event = useRequestEvent()
event.res.statusCode = 404
}
definePageMeta({
middleware: 'auth'
})
useContentHead(page)
</script>
<template>
<div class="document-driven-page">
<NuxtLayout :name="layout || 'default'">
<ContentRenderer v-if="page" :key="page._id" :value="page">
<template #empty="{ value }">
<DocumentDrivenEmpty :value="value" />
</template>
</ContentRenderer>
<DocumentDrivenNotFound v-else />
</NuxtLayout>
</div>
</template>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I want to modify this code show a different page depending on the status code returned by the content query. In my case I have a server middleware that returns 403 if the user has no access to the content. How can I get the http status?
Beta Was this translation helpful? Give feedback.
All reactions