# Prismic Preview feature doesn't work on Prod site

**URL:** <https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375>\
**Category:** Developing with Prismic\
**Tags:** nextjs\
**Created:** [October 8, 2021, 1:25am UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375 "2021-10-08T01:25:04Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![andyrockport8](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@andyrockport8](https://community.prismic.io/u/andyrockport8)\
**Post date:** [October 8, 2021, 1:25am UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/1 "2021-10-08T01:25:04Z")

</div>

Hi, Prismic Support team!

I've encountered the issue of Prsmic Preview.  
It works well on my local dev but now works on a live site.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/d/d0be57d476e9aaee9d8e403c024ba5a5cd4e1bcf.png)

Just shows a 404 error page.

> [@Preview feature not working in Production on drafts (NextJs)](https://community.prismic.io/t/preview-feature-not-working-in-production-on-drafts-nextjs/2676):
>
> Hello, I'm having some problems implementing previews on unpublished documents in production. In development it works as expected no issues what so ever. my preview code is the same as in the documentation: const Preview = async (req, res) =\> { const { token: ref, documentId } = req.query; const redirectUrl = await Client(req) .getPreviewResolver(ref, documentId) .resolve(linkResolver, "/"); if (!redirectUrl) { return res.status(401).json({ message: "Invalid token" }); } res.se…

I've referenced many articles include the above article but have not found the solution yet.

Please solve my problem.  
Thanks

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [October 8, 2021, 12:44pm UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/3 "2021-10-08T12:44:39Z")

</div>

Hi Yuri,

I'll be happy to help.

Can you show me and example of one your page files which has previews configured?

Even better if you can give me a GitHub link to your repo so I can recreate this issue on my side.

Thanks

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [October 11, 2021, 10:24am UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/5 "2021-10-11T10:24:18Z")

</div>

Hi Yurii,

So I looked at your project and there are no Slice or content in your `landing_page` type documents that correspond to components in your pages which is most likely breaking your previews in production. It's hard to really know if previews are working locally in your project like this as you have page structures in your project that doesn't match the page structure of the data coming from Prismic.

I would try and have a fully working page locally before testing on Production. Let me know how this goes once you test it.

Thanks.

---

<div class="post-metadata">

**Author:** ![andyrockport8](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@andyrockport8](https://community.prismic.io/u/andyrockport8)\
**Post date:** [October 11, 2021, 10:48am UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/6 "2021-10-11T10:48:29Z")

</div>

Hi, Phil  
Thanks for your effort.

I've changed my project structure.  
Could you check again?

---

<div class="post-metadata">

**Author:** ![andyrockport8](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@andyrockport8](https://community.prismic.io/u/andyrockport8)\
**Post date:** [October 11, 2021, 11:35am UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/7 "2021-10-11T11:35:51Z")

</div>

Does it work now?

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [October 11, 2021, 12:41pm UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/8 "2021-10-11T12:41:42Z")

</div>

Hi Yurii,

No unfortunately the project still doesn't work as the data contained in Prismic is not represented on your published pages so I can't start debugging what might be wrong in your production site if I can't see the Prismic content locally. I would recommend having a fully working page with Prismic data before working on Previews. Previews are usually the last thing we work on when we build our Sample projects so that we are sure the data is parsed when delivered form the API.

Also, your page that you are testing with has the `uid` of `test-page` when you already have a file in your next.js pages structure of the name `test-page`, this creates a conflict in Next.js as pre-defined routes take precedence over dynamic routes. So this could be causing you prod issues as the preview cookie might be loaded on the wrong file.

> **[Routing: Dynamic Routes | Next.js](https://nextjs.org/docs/routing/dynamic-routes#caveats)**
>
> Dynamic Routes are pages that allow you to add custom params to your URLs. Start creating Dynamic Routes and learn more here.

Try starting with our Blog example to see how we recommend configuring your project:

> **[Getting Started Next.js without Slice Machine](https://prismic.io/docs/technologies/getting-started-examples-simple-nextjs#sample-blog)**
>
> This article lists different sample boilerplates that we've created to help you launch Next.js project with Prismic.

Thanks.

---

<div class="post-metadata">

**Author:** ![andyrockport8](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@andyrockport8](https://community.prismic.io/u/andyrockport8)\
**Post date:** [October 11, 2021, 12:56pm UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/9 "2021-10-11T12:56:05Z")

</div>

You can test with index.js(landing page) `uid` of `home`, not test-page.

It working well with full working page with Prismic Data

Did you test my project on your local?

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [October 11, 2021, 1:19pm UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/10 "2021-10-11T13:19:43Z")

</div>

I tested that page as well and none of the content from Prismic is templated there, only the word Post. This is because your link resolver is directing anything from the `landing_page` custom type towards the the `[uid].js` file. You can learn about how the link resolver works here:

> **[Create Simple URLs (Link Resolver) with Next.js](https://prismic.io/docs/technologies/link-resolver-nextjs)**
>
> This article will teach you how to create simple URLs for links to your Prismic documents using the Link Resolver with Next.js

Preview mode uses the link resolver to find the page on which to load your content.

---

<div class="post-metadata">

**Author:** ![andyrockport8](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@andyrockport8](https://community.prismic.io/u/andyrockport8)\
**Post date:** [October 11, 2021, 1:47pm UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/11 "2021-10-11T13:47:51Z")

</div>

Just I've changed link Resolver.

As I told you it works well on my local but still doesn't work on the live site.

---

<div class="post-metadata">

**Author:** ![andyrockport8](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@andyrockport8](https://community.prismic.io/u/andyrockport8)\
**Post date:** [October 11, 2021, 2:35pm UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/12 "2021-10-11T14:35:19Z")

</div>

![image](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/8/8599254a76978c80efdd7fd50c939996ec1daaf3.png)

It shows 404 page

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [October 12, 2021, 4:12pm UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/13 "2021-10-12T16:12:06Z")

</div>

So I deployed your application on Vercel and saw this warning:

```auto
warn - Statically exporting a Next.js application via `next export` disables API routes.

```

This means previews are being disabled.

> **[Understanding "API Routes in Static Export" Warning in Next.js](https://nextjs.org/docs/messages/api-routes-static-export)**
>
> This document explains the "API Routes in Static Export" warning in Next.js and offers steps to resolve it.

To fix this for now, in your package.json change...

```auto
"build": "next build && next export",

```

to...

```auto
"build": "next build",

```

Your website will still be deployed statically, it will just allow previews to work. To quote the [Next.js docs link](https://nextjs.org/docs/messages/api-routes-static-export) above:

> Pages in your application without server-side data dependencies will be automatically statically exported by `next build` , including pages powered by `getStaticProps`

Let me know if this is clear for you.

Thanks.

---

<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 18, 2021, 10:50am UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/14 "2021-10-18T10:50:18Z")

</div>

closed on October 18, 2021, 10:50am UTC as resolved,  flag & select 'Something Else' to reopen.

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:22pm UTC](https://community.prismic.io/t/prismic-preview-feature-doesnt-work-on-prod-site/7375/15 "2021-12-09T15:22:47Z")

</div>

Opened on December 9, 2021, 3:22pm UTC


