# Prismic Preview with Static Nuxt + Netlify not working

**URL:** <https://community.prismic.io/t/prismic-preview-with-static-nuxt-netlify-not-working/7449>\
**Category:** Developing with Prismic\
**Tags:** nuxtjs\
**Created:** [October 13, 2021, 7:02pm UTC](https://community.prismic.io/t/prismic-preview-with-static-nuxt-netlify-not-working/7449 "2021-10-13T19:02:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![grafik](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/grafik/32/2875_2.png) [@grafik](https://community.prismic.io/u/grafik)\
**Post date:** [October 13, 2021, 7:02pm UTC](https://community.prismic.io/t/prismic-preview-with-static-nuxt-netlify-not-working/7449/1 "2021-10-13T19:02:23Z")

</div>

Hi there,

I'm having trouble getting the preview working with Prismic and a static Nuxt site deployed on Netlify.

Have read through the preview troubleshooting, and this forum (where I see a lot of preview not working posts).

My nuxt.config is setup like this:

```auto

export default {
    ssr: "true",
    loading: false,
    target: "static",
    generate: {
      fallback: "true",
    },
    plugins: ["~/plugins/vue-imgix.js"],
    
    components: true,
  
    buildModules: ["@nuxtjs/prismic", "@nuxtjs/dotenv"],
  
    modules: ["@nuxtjs/style-resources"],
  
    prismic: {
      endpoint: "https://reponame.prismic.io/api/v2",
      linkResolver: "@/plugins/link-resolver",
      preview: "/preview",
    },
  };

```

I'm using a link-resolver as follows:

```auto
export default function (doc) {
  if (doc.isBroken) {
    return "/error";
  }

  if (doc.type === "home_page") {
    return "/";
  }

  if (doc.type === "work_page") {
    return "/work/";
  }

  if (doc.type === "contact_page") {
    return "/contact/";
  }

  if (doc.type === "insights_page") {
    return "/insights/";
  }

  if (doc.type === "about_page") {
    return "/about/";
  }

  if (doc.type === "studio_page") {
    return "/studio/";
  }

  if (doc.type === "menu") {
    return "/";
  }

  if (doc.type === "social") {
    return "/";
  }

  if (doc.type === "category") {
    return "/";
  }

  if (doc.type === "page") {
    return "/page/" + doc.uid;
  }
  if (doc.type === "project") {
    return "/project/" + doc.uid;
  }

  if (doc.type === "article") {
    return "/insight/" + doc.uid;
  }

  return "/";
}

```

Here is how my setup is on the prismic end:

 ![Screen Shot on 2021-10-14 at 08:20:19](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/1/1a9873e1013a63e386765b0ffe05ac24a7658bfc.png)

The io.prismic.preview cookie is added to the application with a value of:

```auto
{%22_tracker%22:%22tf9wCT0N%22%2C%22reponame.prismic.io%22:{%22preview%22:%22https://reponame.prismic.io/previews/YWcwhhQAACEAtWHi:YWcxkxQAACIAtWal?websitePreviewId=YWX2OxQAACEAsFfh%22}}

```

At the moment preview just redirects to the homepage everytime. ¯\_(ツ)\_/¯

Any tips as to what I am doing wrong would be great, as this is a feature I'd love for my clients to be able to use!

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [October 14, 2021, 9:07am UTC](https://community.prismic.io/t/prismic-preview-with-static-nuxt-netlify-not-working/7449/3 "2021-10-14T09:07:40Z")

</div>

Hello @grafik

Thanks for reaching out to us.

If you add the preview route as `/preview,` you need only to set up the preview environment inside your repository, as you already have done. You don't need to add any configuration and preview toolbar in the `nuxt.config.js` file. It's a built-in feature included in the `@nuxtjs/prismic` library.

Could you please remove `preview: "/preview"` from the nuxt.config.js file?

Give this a try, and let me know if it still doesn't work. I'd be happy to debug it.

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![grafik](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/grafik/32/2875_2.png) [@grafik](https://community.prismic.io/u/grafik)\
**Post date:** [October 14, 2021, 7:03pm UTC](https://community.prismic.io/t/prismic-preview-with-static-nuxt-netlify-not-working/7449/4 "2021-10-14T19:03:13Z")

</div>

Hi Priyanka, thanks, ok giving that a go — will report back

---

<div class="post-metadata">

**Author:** ![grafik](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/grafik/32/2875_2.png) [@grafik](https://community.prismic.io/u/grafik)\
**Post date:** [October 14, 2021, 7:38pm UTC](https://community.prismic.io/t/prismic-preview-with-static-nuxt-netlify-not-working/7449/5 "2021-10-14T19:38:50Z")

</div>

Hi Priyanka, that seems to do the trick, initially, I noticed that the project document was not previewing then I checked the link-resolver and realised that it should be named case\_study. 🤦‍♂️

A question in regards to the preview, do you have to click the close on the toolbar to remove the cookie/stop it previewing when you load the page again?

If anyone has a similar problem, this was my setup below to get the preview for a static site working on Netlify.

nuxt.config.js

```auto
    ssr: "true",
    loading: false,
    target: "static",
    generate: {
       fallback: "404.html",
    },
    prismic: {
      endpoint: "https://your-repo-name.prismic.io/api/v2",
      linkResolver: "@/plugins/link-resolver",
    },

```

Link-resolver.js (these must match your nuxt config document type API id's)

My setup:

```auto
export default function (doc) {
  if (doc.isBroken) {
    return "/error";
  }

  if (doc.type === "home_page") {
    return "/";
  }

  if (doc.type === "work_page") {
    return "/work/";
  }

  if (doc.type === "contact_page") {
    return "/contact/";
  }

  if (doc.type === "insights_page") {
    return "/insights/";
  }

  if (doc.type === "about_page") {
    return "/about/";
  }

  if (doc.type === "studio_page") {
    return "/studio/";
  }

  if (doc.type === "menu") {
    return "/";
  }

  if (doc.type === "social") {
    return "/";
  }

  if (doc.type === "category") {
    return "/";
  }

  if (doc.type === "page") {
    return "/page/" + doc.uid;
  }
  if (doc.type === "case_study") {
    return "/project/" + doc.uid;
  }

  if (doc.type === "article") {
    return "/insight/" + doc.uid;
  }

  if (doc.type === "preview") {
    return "/preview" + doc.uid;
  }

  return "/";
}

```

Make sure you have the @nuxtjs/prismic dependency added to your project (this way you do not have to include the prismic toolbar js file)

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [October 19, 2021, 9:10am UTC](https://community.prismic.io/t/prismic-preview-with-static-nuxt-netlify-not-working/7449/8 "2021-10-19T09:10:54Z")

</div>

Hello @grafik

I am glad that it's working for you.

> [@grafik](#):
>
> A question in regards to the preview, do you have to click the close on the toolbar to remove the cookie/stop it previewing when you load the page again?

Yes, When you're done previewing, click on the "X" in the preview toolbar to exit your preview session.

Don't hesitate to reach out to us if you have any questions.

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [October 20, 2021, 12:30pm UTC](https://community.prismic.io/t/prismic-preview-with-static-nuxt-netlify-not-working/7449/9 "2021-10-20T12:30:40Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [December 9, 2021, 3:21pm UTC](https://community.prismic.io/t/prismic-preview-with-static-nuxt-netlify-not-working/7449/10 "2021-12-09T15:21:39Z")

</div>


