Fix SEO: www base URL + skip middleware for tool rewrites#832
Draft
PavelMakarchuk wants to merge 2 commits intomainfrom
Draft
Fix SEO: www base URL + skip middleware for tool rewrites#832PavelMakarchuk wants to merge 2 commits intomainfrom
PavelMakarchuk wants to merge 2 commits intomainfrom
Conversation
- Change BASE_URL from policyengine.org to www.policyengine.org (non-www 307-redirects to www, so all canonical URLs and OG tags generated by middleware pointed to a redirecting URL) - Skip middleware interception for paths that Vercel rewrites to external apps (KYPA, WATCA, TAXSIM, API docs). These apps have their own SSR with full content, meta tags, OG images, and JSON-LD. The middleware was replacing rich SSR pages with 3-line stubs, preventing Google from seeing the actual content. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WATCA lacks its own OG tags — bypassing middleware would break social share previews. Also fixes DEFAULT_OG.image to use www. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 tasks
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.
Summary
BASE_URL: Change frompolicyengine.orgtowww.policyengine.org. The non-www domain 307-redirects to www, so all canonical URLs and OG tags generated by middleware pointed to a redirecting URL. This affects all pages served by the middleware.DEFAULT_OG.image: Also used non-www./us/keep-your-pay-act,/us/taxsim, and/us/apiare Vercel-rewritten to external Next.js apps that have their own SSR, meta tags, OG images, and JSON-LD. The middleware was intercepting Googlebot and replacing these rich SSR pages with a 3-line HTML stub containing only a title, description, and link — preventing Google from seeing the actual content.Context
/us/keep-your-pay-actis not appearing in Google search results despite being live for 4+ days. Investigation found:curl -A "Googlebot" https://www.policyengine.org/us/keep-your-pay-actreturns a minimal stub HTML page from middleware instead of the full SSR calculator pagehttps://policyengine.org/...(no www), which 307-redirects — a confusing signal for Google indexerThe middleware stub Googlebot currently receives is just an h1, a one-line description, and a link — while the actual SSR page has the full calculator with policy overview, charts, tables, form inputs, semantic HTML, heading hierarchy, and rich content.
Companion PR with app-side fixes: PolicyEngine/keep-your-pay-act#31
Risk assessment
Tool-by-tool bypass assessment
Each rewritten tool was checked to see if it has its own meta tags before bypassing middleware:
/us/keep-your-pay-act/us/watca/us/taxsim/us/apiKnown remaining issues (not in scope)
app/public/sitemap.xmlandapp/scripts/generate-sitemap.tsuse non-www URLs for all 253 pages — same mismatch but a larger change, should be a separate PRapp/public/robots.txtsitemap directive uses non-wwwTest plan
curl -A "Googlebot" https://www.policyengine.org/us/keep-your-pay-actreturns the full SSR page (not the 3-line stub)curl -A "Googlebot" https://www.policyengine.org/us/research/some-poststill returns the pre-rendered/OG response (middleware still works for non-rewrite paths)curl -A "Twitterbot" https://www.policyengine.org/us/watcastill returns OG stub with image (not bypassed)https://www.policyengine.org/us/keep-your-pay-actGenerated with Claude Code