Repository navigation
fix(web): inline the build-time site origin for the function runtime (variant) - #246
Open
damianrosellen1 wants to merge 1 commit into
Open
damianrosellen1 wants to merge 1 commit into
damianrosellen1 wants to merge 1 commit into
Conversation
`siteUrl.ts` falls back to Netlify's `URL` / `DEPLOY_PRIME_URL`, which only exist at build. The function runtime that serves ISR regenerations and route handlers lacks them, so canonicals and the sitemap fell back to `http://localhost:3000` on every deploy without `NEXT_PUBLIC_SITE_URL`, deploy previews included. `next.config.ts` now resolves the origin at build and inlines it as `NEXT_PUBLIC_SITE_URL`. Netlify's production context now always takes `URL`: a staging site on the development dataset (`SANITY_STUDIO_DEPLOYMENT_TARGET=development`) serves the primary domain, where `DEPLOY_PRIME_URL` is the `<branch>--` host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 18e6f96)
There was a problem hiding this comment.
🟢 Approval recommended
The focused changes address the runtime fallback while preserving existing origin overrides and preview behavior, with no blocking issues identified.
No open issues 🎉
What changed in this PR
Ports #245 to the document-level variant, preserving the build-time site origin for Netlify runtime rendering instead of falling back to localhost.
Changes:
- Inlines the resolved origin as
NEXT_PUBLIC_SITE_URLthrough Next.js configuration. - Uses Netlify’s primary URL in production context, including staging sites, while preserving explicit overrides and preview behavior.
- Updates documentation to explain the origin-selection rules.
| File | Description |
|---|---|
web/src/utils/siteUrl.ts |
Adjusts Netlify production-context origin selection and documents build-time resolution. |
web/next.config.ts |
Inlines the resolved site origin for runtime use. |
packages/sanity-dataset-resolve/src/index.ts |
Updates a comment describing the Netlify canonical-origin exception. |
Review effort: Balanced
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.
Port of #245 by
git cherry-pick -x, no conflicts:web/next.config.ts,web/src/utils/siteUrl.tsandpackages/sanity-dataset-resolveare identical on both branches.On Netlify, canonicals,
hreflang,og:urland the sitemap fell back tohttp://localhost:3000on any deploy withoutNEXT_PUBLIC_SITE_URL: Netlify'sURL/DEPLOY_PRIME_URLexist at build but not in the function runtime that serves ISR regenerations and route handlers.next.config.tsnow resolves the origin at build and inlines it asNEXT_PUBLIC_SITE_URL, and Netlify's production context always takesURL(a staging site on the development dataset serves its primary domain). Details in #245.Verified
pnpm typecheck,pnpm linton this branch.http://localhost:3000.Variant-Port: #245
🤖 Generated with Claude Code