feat: block scraping and rewrite canonical on preview builds#2566
Open
vladfrangu wants to merge 4 commits into
Open
feat: block scraping and rewrite canonical on preview builds#2566vladfrangu wants to merge 4 commits into
vladfrangu wants to merge 4 commits into
Conversation
Adds a postBuild plugin that, for PR/preview deployments, overwrites robots.txt with a global Disallow and rewrites every page's canonical link to point at docs.apify.com so search engines don't index previews or compete with production URLs.
The original regex required quotes around `canonical` and the fallback inserted before `</head>`. Both forms are stripped by the SWC HTML minimizer, so neither branch fired against real build output and the canonical rewrite shipped as dead code. Make the regex quote-optional, add a `<body` fallback for the closing-tag-less case, and special-case `404.html` to match the production canonical form.
Contributor
|
✅ Preview for this PR (commit |
Member
Author
|
(staff-review was already ran) |
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.
Adds a postBuild plugin that, on PR/preview deployments (detected via
APIFY_DOCS_ABSOLUTE_URLhostname, same heuristic as the existing preview banner), overwritesrobots.txtwith a globalDisallow: /and rewrites every page's canonical link to point athttps://docs.apify.com{path}. Keeps previews out of search indexes and prevents them from competing with production URLs.The second commit handles SWC's HTML minifier stripping attribute quotes and omitting
</head>— without it the canonical rewrite would have shipped as dead code (caught by staff-review against the actual build output).