patronage / bubs-next

Headless Wordpress + Next.js Project scaffolding
https://bubs-next.vercel.app
MIT License
37 stars 10 forks source link

fix: nodeByUri/graphcdn fix #256

Closed kylehotchkiss closed 1 year ago

kylehotchkiss commented 1 year ago

This resolves a steady issue causing graphcdn to email us a generic error occurring across a variety of projects.

In #229 we narrowed down that issue to Wordpress supported but not bubs-next supported pathnames for taxonomies. To solve, this PR adds an additional check inside of getStaticContent which verifies that a pathname is actually a contentNode before we try querying contentNode for that path. The function can tell us whether a URL is a contentNode (which we always render), a termNode (we don't render) or neither (for example, a redirect or an actual 404).

This nice thing about this solve instead of hardrcoding a set of taxonomies which is going to change across different projects, we can actually check the source of truth on project taxonomies (which is Wordpress)

An example of this fix in practice: In production, a 500 error: https://www.nextgenpolicy.org/category/advisory/ In the preview branch with this fix, a 404 http://nextgenpolicy-by91aal7d-patronage.vercel.app/category/advisory/

TODO:

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
bubs-next ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 11, 2023 at 11:29PM (UTC)
ccorda commented 1 year ago

Correcting myself, it's not our api routes (/sitemap.xml and /feed) work fine. But anything random, like /foo.

I get this in ..slug

TypeError: Cannot read properties of null (reading 'isContentNode')
This error happened while generating the page. Any console logs will be displayed in the terminal window.