Skip to content

fix: resolve base URL using production domain instead of deployment URL#128

Merged
liamwalder merged 2 commits intodevelopfrom
fix/base-url
Apr 3, 2026
Merged

fix: resolve base URL using production domain instead of deployment URL#128
liamwalder merged 2 commits intodevelopfrom
fix/base-url

Conversation

@liamwalder
Copy link
Copy Markdown
Collaborator

Summary

OG image, sitemap, and robots.txt URLs resolve against the Vercel
deployment URL (e.g. my-app-abc123.vercel.app) instead of the actual
production domain. This happens because VERCEL_URL is the last
fallback and returns the per-deployment URL, not the configured domain.

Changes

  • Add getSiteBaseUrl utility to centralize base URL resolution across the app
  • Replace scattered inline getBaseUrl() functions in robots.txt and sitemap routes
  • Explicitly set metadataBase on page metadata so Next.js resolves relative URLs correctly
  • Add VERCEL_PROJECT_PRODUCTION_URL as a fallback before VERCEL_URL, which automatically returns the production domain configured in Vercel
  • Batch settings queries in robots.txt and sitemap routes via getSettingsByKeys

Test plan

  • Deploy to Vercel with a custom domain and verify og:image meta tag uses the production domain, not the deployment URL
  • Check sitemap.xml URLs reference the production domain
  • Check robots.txt sitemap reference uses the production domain
  • Verify setting global_canonical_url in site settings still takes priority
  • Verify pages remain statically cached (ISR not broken)

Made with Cursor

tristan-mouchet and others added 2 commits April 3, 2026 11:35
…tion

- Added a new utility function `getSiteBaseUrl` to centralize the logic for resolving the site's base URL from various settings and environment variables.
- Updated multiple components and routes to utilize this new utility, ensuring consistent base URL handling across the application.
- Refactored metadata generation functions to improve clarity and maintainability.
VERCEL_URL resolves to the deployment-specific URL (e.g.
my-app-abc123.vercel.app) which produces incorrect og:image
and sitemap URLs in production. VERCEL_PROJECT_PRODUCTION_URL
returns the actual production domain configured in Vercel.

Made-with: Cursor
@liamwalder liamwalder merged commit 68b85e6 into develop Apr 3, 2026
3 checks passed
@liamwalder liamwalder deleted the fix/base-url branch April 3, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants