Preview error on nuxt 3 SSR using v3 module
See original GitHub issueHello there, Iโm having issues with the preview on nuxt 3 & @nuxtjs/prismic v3.
I configured the preview in prismic as such:
Domain: http://localhost:3000 Link resolver: /preview
When launching the preview, the server throws a 500 error, useHead is not defined
.
I also deployed & configured it on Netlify, and Iโm getting the same error in a live environment.
I also tried my luck making a custom preview file pages/preview.vue
but Iโm getting the same exact error.
Versions
- nuxt: 3.0.0-rc.4
- @nuxtjs/prismic: 3.0.0-alpha.5
- node: 16.14.2
Additional Details
nuxt.config.ts
import { defineNuxtConfig } from 'nuxt'
import svgLoader from 'vite-svg-loader'
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
buildModules: [
'@pinia/nuxt',
'@vueuse/nuxt',
'@intlify/nuxt3',
],
modules: [
'@nuxtjs/tailwindcss',
'@nuxtjs/prismic',
],
prismic: {
endpoint: 'xxxx',
},
intlify: {
localeDir: 'locales',
vueI18n: {
locale: 'en-gb',
fallbackLocale: 'en-gb',
}
},
components: {
dirs: [
{ path: '~/components', global: false},
{ path: '~/slices', global: false },
],
},
runtimeConfig: {
public: {
}
},
vite: {
plugins: [
svgLoader(),
]
}
})
nuxt dev
console
[Vue warn]: Unhandled error during execution of setup function
at <Preview onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > key="/preview" >
[nuxt] [request error] useHead is not defined
at setup (./.nuxt/dist/server/server.mjs:22715:1)
at _sfc_main.setup (./.nuxt/dist/server/server.mjs:22755:23)
.nuxt/dist/server/server.mjs
const _sfc_main = {
__name: 'preview',
setup(__props, { expose }) {
expose();
useHead({ // <---- Error thrown here
title: 'Prismic Preview - Loading'
})
// TODO: refactor into simple hook
const { client, options: { linkResolver } } = usePrismic()
const { push } = useRouter()
__vite_ssr_import_0__.onMounted(async () => {
const redirectURL = await client.resolvePreviewURL({
linkResolver,
defaultURL: '/'
})
push(redirectURL ?? '/')
})
Steps to reproduce
- Install and configure
@nuxtjs/prismic
innuxt.config.ts
- Setup preview on prismic
- Click the preview icon in UI
- Error
useHead is not defined
shows up
What is Expected?
Preview working properly
What is actually happening?
Error 500
useHead is not defined
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:15
Top Results From Across the Web
nuxt.js - Not able to preview NuxtJs3 build - Stack Overflow
My Nuxt 3 Project is suddenly giving me some error after release of 3.0.0-rc.5, it used to work well and now i am...
Read more >v3.0.0-rc.10 ยท Discussion #7513 ยท nuxt/framework - GitHub
This feature helps to improve the First Contentful Paint (FCP) metric. You can disable the feature from nuxt.config using experimental: { inlineSSRStyles:ย ...
Read more >Error handling ยท Get Started with Nuxt
Learn how to catch errors in different lifecycle. Handling Errors. Nuxt 3 is a full-stack framework, which means there are several sources of...
Read more >Preview Mode - Nuxt
The preview mode will automatically refresh the page data as it uses $nuxt.refresh under the hood and therefore calls nuxtServerInit, asyncData and fetch...
Read more >How to Configure SSG and SSR on Nuxt.js - Mad Devs
Storing; SSG; SSR. Separately, I will show you how to set up SSG, SSR in production and create your own API using nuxt...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the follow up and the commits ๐๐๐๐
And also a big thank you for this article: https://lihbr.com/blog/pushing-nuxt-js-static-generation-one-step-further At the time, this approach provided excellent performance
Alright,
3.0.0-alpha.10
should be the one ๐Edit: Just tried with the production package, works as expected ๐