GatsbyJS Unpublished Page Previews (e.page.data is undefined)

Hey, I am working on getting previews to work with GatsbyJS - I have previews working across the board with anything that has been published or was previously published and now has new content that is being previewed.

I am unfortunately unable to get the previews to work for Unpublished pages, it seems to resolve fine through the linkResolver and i have logged through corrosponding pages that would route such as 404, Preview, Link Resolver, Page.

(the link) [prismic-gatsby/starters/gatsby-starter-prismic/src/pages at main · prismicio/prismic-gatsby · GitHub]

I recieve the following error message

Uncaught ( in promise ) TypeError: can't access property "data", e.data.page is undefined

I have an extremely similar set up as to the following github link, the only difference is that I am sourcing a template file rather than using the pages/{PrismicPage.url}.js page. The rest of the set up is the same though.

Any pointers?

Hello @james.harrison, have you followed the Preview documentation?
This document explains how to setup the 4040 page to work with unpublished documents using withPrismicUnpublishedPreview

You can also check out this blog starter that uses templates for the pages, similarly to your project