fix: Substack Cloudflare block + getSitePosts crash + build resilience - #4
Merged
Merged
Conversation
❌ Deploy Preview for soft-swan-5d0ce7 failed. Why did it fail? →
|
✅ Deploy Preview for darling-dusk-441006 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- is_published === true was silently dropping posts where the field is absent (common on the public API) — changed to !== false so only explicitly unpublished posts are excluded - Replace log() calls with console.error() so fetch errors always appear in CI output regardless of LOG_LEVEL / DEBUG env vars - Add permanent 'Read on Substack' link at the top of the essays section as a reliable fallback if the API fetch returns nothing https://claude.ai/code/session_01P9Bn6gkWtM15yEzGf79XCQ
…tSitePosts crash Substack's API is behind Cloudflare bot protection which always returns 403 from GitHub Actions — build-time fetching is not viable. Removed the fetch entirely; Substack content is now surfaced via: - "Read on Substack" link at the top of the essays section - Substack embed iframe (loads client-side, not blocked by Cloudflare) Also fixed getSitePosts crash: collection.name[0][0] threw when collection.name was undefined; added optional chaining so it returns undefined and the early-return guard handles it gracefully. https://claude.ai/code/session_01P9Bn6gkWtM15yEzGf79XCQ
Korede-TA
force-pushed
the
fix/substack-cloudflare-and-build-crashes
branch
from
June 2, 2026 22:17
045a423 to
f13c355
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two commits on top of the merged PR #3 changes.
1. Remove build-time Substack API fetch (
pages/index.tsx,lib/get-substack-essays.ts)The Substack API (
/api/v1/posts) is behind Cloudflare bot protection, which returns a 403 JS challenge page for any non-browser request — including GitHub Actions. This will never work at build time regardless of API key or User-Agent.Removed the
getSubstackEssayscall fromgetStaticPropsentirely. Substack content is now surfaced via two client-side mechanisms that aren't affected by Cloudflare:2. Fix
getSitePostscrash (lib/get-site-posts.ts)collection.name[0][0]threwCannot read properties of undefined (reading '0')whencollection.namewas absent in the Notion response. Added optional chaining (?.) so it returnsundefinedand the existing early-return guard handles it gracefully instead of crashing the build.Test plan
https://claude.ai/code/session_01P9Bn6gkWtM15yEzGf79XCQ
Generated by Claude Code