feat: add /bitget and /binance affiliate redirects with og cards#34
Merged
Conversation
Pure HTTP redirects let social crawlers fall through to the affiliate destination, so shared previews would show Bitget or Binance branding instead of kaiyn's. Serve a real route that branches on User-Agent: bots get an HTML page with OG and Twitter Card meta tags pointing at static 1200x630 images, humans get a 307 straight to the affiliate URL with no visible flash. Both paths are excluded from the next-intl matcher so they keep their naked URLs instead of being rewritten to /en/bitget. Pages are marked noindex so they stay out of search results while remaining crawlable for OG fetchers (most ignore robots.txt anyway).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Why
We want to publish short URLs
kaiyn.org/bitgetandkaiyn.org/binancethat funnel into our affiliate links, but a plain HTTP redirect would
let social crawlers fall through to the destination — shared previews
on Twitter / Discord / LINE / Slack would show Bitget or Binance
branding instead of kaiyn's. We need real HTML at those paths so the
preview cards stay on-brand, while still sending humans straight to
the affiliate destination so the ref code attaches correctly.
How
/bitgetand/binanceare Route Handlers that branch on User-Agent:facebookexternalhit,Twitterbot,Slackbot,Discordbot,LINE,WhatsApp, etc.) get a 200 with a minimal HTMLdocument containing OG and Twitter Card meta pointing at static
1200×630 images in
public/og/.ref code preserved.
Both paths are excluded from the
next-intlmiddleware matcher so theykeep their naked URLs instead of being rewritten to
/en/bitget. Pagesare marked
noindex,followso they stay out of search results whileremaining crawlable for OG fetchers (most ignore
robots.txtanyway).A Route Handler was preferred over a page under
[locale]/because OGcopy is a single English version and we don't want the locale prefix in
the canonical URL. It's also lighter than introducing parallel root
layouts via route groups.
Test plan
/bitgetreturns307withLocation: https://partner.bitget.site/bg/JZQT5S/binancereturns307withLocation: https://www.binance.com/join?ref=148898758Twitterbot/1.0→/bitgetreturns200 text/htmlwith fullog:*andtwitter:*metafacebookexternalhit/1.1→/binancereturns200with OG meta/og/bitget.pngand/og/binance.pngserve200pnpm buildpasses;/bitgetand/binanceregister as dynamic routes