Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.8k
fix(seo): noindex non-production sim.ai hosts, redirect indexed 404s#5988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
3cbebbc
fix(seo): noindex non-production sim.ai hosts, redirect indexed 404s
waleedlatif1 c8dd699
fix(seo): parse only the first entry of a comma-joined forwarded host
waleedlatif1 4a304f1
fix(seo): drop the /security redirect, complete the urls test mock
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -531,6 +531,28 @@ const nextConfig: NextConfig = { | ||
| } | ||
| ) | ||
| /** | ||
| * Indexed 404s from an external SEO audit. The capability paths read as | ||
| * tool/feature pages and map to the integrations catalog; the rest have no | ||
| * closer successor than the homepage. | ||
| * | ||
| * `/security` is deliberately excluded: security.txt advertises it as the | ||
| * RFC 9116 `Policy` URI, so a permanent redirect to marketing would both | ||
| * mislead that link and shadow a real policy page added later. | ||
| */ | ||
| redirects.push( | ||
| ...['read', 'research', 'scrape'].map((slug) => ({ | ||
| source: `/${slug}`, | ||
| destination: '/integrations', | ||
| permanent: true, | ||
| })), | ||
| ...['actions', 'crawl', 'fast'].map((slug) => ({ | ||
| source: `/${slug}`, | ||
| destination: '/', | ||
| permanent: true, | ||
| })) | ||
waleedlatif1 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ) | ||
| return redirects | ||
| }, | ||
| async rewrites() { | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -6,6 +6,7 @@ import { getEnv } from './lib/core/config/env' | ||
| import { isAuthDisabled, isDev, isHosted } from './lib/core/config/env-flags' | ||
| import { generateRuntimeCSP } from './lib/core/security/csp' | ||
| import { getClientIp } from './lib/core/utils/request' | ||
| import { isNonCanonicalSimHost } from './lib/core/utils/urls' | ||
| const logger = createLogger('Proxy') | ||
| @@ -297,10 +298,31 @@ export async function proxy(request: NextRequest) { | ||
| return track(request, response) | ||
| } | ||
| /** | ||
| * Keeps non-production sim.ai deployments out of search results. | ||
| * | ||
| * `noindex` rather than a robots.txt `Disallow` is deliberate: a disallowed URL | ||
| * can still be indexed when linked externally, and blocking the crawl stops | ||
| * search engines from ever seeing the directive that removes pages already in | ||
| * the index. robots.txt is excluded from this proxy's matcher so it keeps | ||
| * serving the crawlable rules this header depends on. | ||
| */ | ||
| function applyIndexingPolicy(request: NextRequest, response: NextResponse): void { | ||
| const host = | ||
| request.headers.get('x-forwarded-host')?.split(',')[0]?.trim() || | ||
| request.headers.get('host') || | ||
| request.nextUrl.host | ||
| if (isNonCanonicalSimHost(host)) { | ||
waleedlatif1 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| response.headers.set('X-Robots-Tag', 'noindex, nofollow') | ||
| } | ||
| } | ||
| /** | ||
| * Sends request data to Profound analytics (fire-and-forget) and returns the response. | ||
| */ | ||
| function track(request: NextRequest, response: NextResponse): NextResponse { | ||
| applyIndexingPolicy(request, response) | ||
| sendToProfound(request, response.status) | ||
| return response | ||
| } | ||
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
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.