nuxt-modules / prismic

Easily connect your Nuxt.js application to your content hosted on Prismic

Home Page:https://prismic.nuxtjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prismic's Toolbar isn't initialized when Nuxt's globalName has been modified

egstad opened this issue · comments

[Outdated - see comment below]

I've noticed that the Prismic Toolbar has been missing over the last few releases. I've tried clearing cache, deleting cookies, deleting .nuxt files, updating my npm packages, but no dice. Anyone else run into this issue and solve it?

I get these warnings in the console, but don't see how map files would cause this error.
image

Versions I've tested on and
nuxt: 2.11.2 - 2.12.2
@nuxtjs/prismic: 1.1.0 - 1.2.1. Also tried this on the #get-preview-resolver branch

Here is my nuxt.config.js.

  prismic: {
    endpoint,
    linkResolver: '@/plugins/prismic/prismic-link-resolver.js',
    htmlSerializer: '@/plugins/prismic/prismic-html-serializer.js',
    preview: '/preview/'  
  },

Would appreciate any assistance here. Without the toolbar, I've lost the ability to view anything but Prismic's master branch and create shareable staging links.

Thank you!

I've found the issue...

This package doesn't hold nuxt's globalName into account. This is what is called in prismic.js.

  // Load prismic script after Nuxt app is mounted
  if (process.client) {
    window.onNuxtReady && window.onNuxtReady(() => {
      const script = document.createElement('script')

      script.src = '<%= options.script %>'
      document.body.appendChild(script)
    })
  }

My globalName is set to app, meaning that onNuxtReady becomes onAppReady. Upon changing the above to the following, the preview toolbar is back...

  // Load prismic script after Nuxt app is mounted
  if (process.client) {
    window.onAppReady && window.onAppReady(() => {
      const script = document.createElement('script')

      script.src = '<%= options.script %>'
      document.body.appendChild(script)
    })
  }

This update makes the toolbar operational. It's not perfect though - i'm receiving a polling iframe error every ~3 seconds.
image

We are having this issue as well. What's the solution without having to change our global name back?