Skip to content

fix(core): preview deployments now use correct metadataBase#2890

Merged
jorgemoya merged 4 commits intocanaryfrom
cataylyst-1772-fix-canonical-preview-envs
Feb 18, 2026
Merged

fix(core): preview deployments now use correct metadataBase#2890
jorgemoya merged 4 commits intocanaryfrom
cataylyst-1772-fix-canonical-preview-envs

Conversation

@jorgemoya
Copy link
Contributor

What/Why?

On Vercel preview deployments (VERCEL_ENV=preview), metadataBase and canonical/hreflang URLs use VERCEL_URL instead of the production vanity URL to prevent preview environments from generating SEO metadata pointing to production.

Testing

Preview deployment/unlighthouse score

Migration

N/A

@jorgemoya jorgemoya requested a review from a team as a code owner February 17, 2026 18:58
@vercel
Copy link

vercel bot commented Feb 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
catalyst Ready Ready Preview, Comment Feb 18, 2026 6:13pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Feb 17, 2026

⚠️ No Changeset found

Latest commit: e829f00

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Patch

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

// Use preview deployment URL so metadataBase (canonical, og:url) points at the preview, not production.
let baseUrl: URL | undefined;

if (process.env.VERCEL_ENV === 'preview' && process.env.VERCEL_URL) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍹 What if instead of checking for a truthy value for process.env.VERCEL_URL we used URL.canParse or at least verified that the URL constructor won't throw.

Same for parsing vanityUrl—do we want to add some logic to check for potential parsing failures?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL about URL.canParse!

Comment on lines 49 to 53
const isPreview = process.env.VERCEL_ENV === 'preview';

if (isPreview && process.env.VERCEL_URL) {
return `https://${process.env.VERCEL_URL}`;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍹 I don't love how this logic is coupled to the getVanityUrl function. It feels like the fallback logic should live at a higher level than here

@jorgemoya jorgemoya force-pushed the cataylyst-1772-fix-canonical-preview-envs branch from 033ee27 to e829f00 Compare February 18, 2026 18:11
@jorgemoya jorgemoya added this pull request to the merge queue Feb 18, 2026
Merged via the queue into canary with commit 7889cfa Feb 18, 2026
11 checks passed
@jorgemoya jorgemoya deleted the cataylyst-1772-fix-canonical-preview-envs branch February 18, 2026 18:28
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