gatsbyjs / wp-gatsby

WordPress plugin for gatsby-source-wordpress
Other
167 stars 41 forks source link

NO_PREVIEW_PATH_FOUND #173

Closed koraysels closed 3 years ago

koraysels commented 3 years ago

I am trying really hard to get gatsby previews working.. but i keep failing.

I setup everything using wpgatsby on the gastby cloud with the wpgatsby plugin. My main build is going to netlify but my preview webhook and preview url is striaght from gatsby cloud.

IIn wordpress if I try to preveiw a published post, I get the gatsby preveiw loader and in the console it keeps repeating:

NO_PREVIEW_PATH_FOUND

I think it has something to do with https://github.com/gatsbyjs/wp-gatsby/blob/a23c2e350b76d09b842246053c848d8ec63aad85/src/Admin/Preview.php#L362-L366

kingkero commented 3 years ago

@koraysels could you solve it?

I'm facing the same problem right now, though not using Gatsby Cloud. If I manually run

curl -X POST -H "Authorization: secret" https://myurl/__refresh

I see the request in the logs of the deployed Gatsby and that it does something. However, from WP I do not see any previews. WP Gatsby is configured with

When clicking preview from WordPress, console is spammed with NO_PREVIEW_PATH_FOUND and the object log is

graphqlEndpoint: "graphql"
postId: 82
previewFrontendUrl: "https://myurl"
previewWebhookIsOnline: false
webhookWasCalled: true
wordpressSiteUrl: "https://wpurl"

Unsure, why it says previewWebhookIsOnline: false here. The preview instance is online and openly available (was first behind Basic Auth, but that is currently disabled).

koraysels commented 3 years ago

I did not solve it yet. Maybe next week i’ll try again. If you find a solution please let me know:) I will do the same

On 18 Jun 2021, at 16:46, Martin Rehberger @.***> wrote:

 @koraysels could you solve it?

I'm facing the same problem right now, though not using Gatsby Cloud. If I manually run

curl -X POST -H "Authorization: secret" https://myurl/__refresh I see the request in the logs of the deployed Gatsby and that it does something. However, from WP I do not see any previews. WP Gatsby is configured with

Enable Gatsby Preview?: checked Preview Instance: https://myurl/ Preview Webhook: https://myurl/__refresh Preview JWT Secret: secret When clicking preview from WordPress, console is spammed with NO_PREVIEW_PATH_FOUND and the object log is

graphqlEndpoint: "graphql" postId: 82 previewFrontendUrl: "https://myurl" previewWebhookIsOnline: false webhookWasCalled: true wordpressSiteUrl: "https://wpurl" Unsure, why it says previewWebhookIsOnline: false here. The preview instance is online and openly available (was first behind Basic Auth, but that is currently disabled).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

kingkero commented 3 years ago

@koraysels so one of the problems was the previewWebhookIsOnline is false in the initial configuration. I think this happens, because currently, the Authroziation header is not used when doing the preview check in https://github.com/gatsbyjs/wp-gatsby/blob/v1.0.10/src/ActionMonitor/Monitors/PreviewMonitor.php#L205

Manually changing the option to true got me one preview, now it hangs on REMOTE_NODE_NOT_YET_UPDATED or still NO_PREVIEW_PATH_FOUND.

@TylerBarnes @jasonbahl any input?

TylerBarnes commented 3 years ago

I believe NO_PREVIEW_PATH_FOUND means there wasn't a page created in Gatsby for the content you're trying to preview if I remember correctly. The error usually has some additional steps below it to try, did you take a look at those?

We also have this doc https://github.com/gatsbyjs/gatsby-source-wordpress-experimental/blob/master/docs/features/preview.md#debugging-the-build-process-of-previews

TylerBarnes commented 3 years ago

Also I'd recommend opening a support ticket from the Gatsby Cloud dashboard. That will make it easier for our team to work with private sites and we can work out having an account added so we can try to preview on your site for debugging as well.

kingkero commented 3 years ago

@koraysels @TylerBarnes Our main issue was permalink structure. Had something individual, but it needs to be /%postname%/ - now it works with a self hosted Gatsby develop as preview.

(Tried Gatsby Cloud - which I happily use for other customers - but as long as it doesn't support private Bitbucket packages, not an option here.)

koraysels commented 3 years ago

I still get the preview path not found error. I installed everything correctly i think. I also added gatsby-plugin-gatsby-cloud ... still no previews.. image

koraysels commented 3 years ago

So if anybody got this working with wordpress, would you like to explain how exactly? thaanks

TylerBarnes commented 3 years ago

@koraysels there isn't a single cause of this issue since many things on the Gatsby side can trigger it. We're working on a new preview loader service which will prevent this from happening but in the meantime did you follow the debugging steps in the error screen?

TylerBarnes commented 3 years ago

I just discovered another possible cause of this issue! Sometimes folks will set up Gatsby to source data from one WP instance, for ex a.com/graphql, and then send previews from a different WP instance, for ex b.com/graphql. This doesn't work because b.com/graphql doesn't have auth creds for a.com/graphql. In https://github.com/gatsbyjs/gatsby/pull/32251 I fixed an internal check for this misconfiguration and the preview loader will display a different warning in the browser with more accurate instructions.

For everyone who's running into this issue, make sure the Gatsby site you're sending webhooks to when you preview is sourcing data from the WP site you're previewing from.

koraysels commented 3 years ago

@TylerBarnes thank you for being so involved. Appreciate it!

@koraysels there isn't a single cause of this issue since many things on the Gatsby side can trigger it. We're working on a new preview loader service which will prevent this from happening but in the meantime did you follow the debugging steps in the error screen?

Well, I don't filter any posts, I added the the node id in pageContext and set the presets to null. I am not sure which other errors I should debug or what you mean by 'error screen'

Krumil commented 3 years ago

Hi! Any news about this? I've checked the source data and it's seems all ok...

TylerBarnes commented 3 years ago

@Krumil this isn't a bug on the WPGatsby side but is an indication of many different potential problems on the Gatsby side, either via source plugin bugs or misconfigurations, or both. Because of that there isn't a way for us to release a single bug fix for it so I'm going to close this issue. Please open a Gatsby Cloud support ticket so we can effectively debug the issue with your specific site. As I mentioned in the slightly longer term we will be replacing the WPGatsby preview loader with a Gatsby Cloud preview loader service. When we do that these types of issues will be much less prevelant because Gatsby Cloud has a lot more context on the build process, the source plugin, and Gatsby core.