fix(core): preview deployments now use correct metadataBase#2890
fix(core): preview deployments now use correct metadataBase#2890
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
| 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
ce5c1fc to
56e52ba
Compare
core/app/[locale]/layout.tsx
Outdated
| // 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) { |
There was a problem hiding this comment.
🍹 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?
There was a problem hiding this comment.
TIL about URL.canParse!
core/lib/seo/canonical.ts
Outdated
| const isPreview = process.env.VERCEL_ENV === 'preview'; | ||
|
|
||
| if (isPreview && process.env.VERCEL_URL) { | ||
| return `https://${process.env.VERCEL_URL}`; | ||
| } |
There was a problem hiding this comment.
🍹 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
033ee27 to
e829f00
Compare
What/Why?
On Vercel preview deployments (
VERCEL_ENV=preview),metadataBaseand canonical/hreflang URLs useVERCEL_URLinstead of the production vanity URL to prevent preview environments from generating SEO metadata pointing to production.Testing
Preview deployment/unlighthouse score
Migration
N/A