Add detection for Google-PageRenderer
bot (#31521)
- Fixes https://github.com/vercel/next.js/discussions/31482
This commit is contained in:
parent
2ad9dac873
commit
d87dc2b5a0
2 changed files with 16 additions and 1 deletions
|
@ -16,7 +16,7 @@ export function cleanAmpPath(pathname: string): string {
|
|||
}
|
||||
|
||||
export function isBot(userAgent: string): boolean {
|
||||
return /Googlebot|Mediapartners-Google|AdsBot-Google|googleweblight|Storebot-Google|Bingbot|BingPreview|Slurp|DuckDuckBot|baiduspider|yandex|sogou|LinkedInBot|bitlybot|tumblr|vkShare|quora link preview|facebookexternalhit|facebookcatalog|Twitterbot|applebot|redditbot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|ia_archiver/i.test(
|
||||
return /Googlebot|Mediapartners-Google|AdsBot-Google|googleweblight|Storebot-Google|Google-PageRenderer|Bingbot|BingPreview|Slurp|DuckDuckBot|baiduspider|yandex|sogou|LinkedInBot|bitlybot|tumblr|vkShare|quora link preview|facebookexternalhit|facebookcatalog|Twitterbot|applebot|redditbot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|ia_archiver/i.test(
|
||||
userAgent
|
||||
)
|
||||
}
|
||||
|
|
|
@ -185,6 +185,21 @@ describe('Concurrent mode', () => {
|
|||
)
|
||||
expect(res.headers.get('etag')).toBeDefined()
|
||||
})
|
||||
|
||||
it('should not stream to google pagerender bot', async () => {
|
||||
const res = await fetchViaHTTP(
|
||||
context.appPort,
|
||||
'/ssr',
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 Google-PageRenderer Google (+https://developers.google.com/+/web/snippet/)',
|
||||
},
|
||||
}
|
||||
)
|
||||
expect(res.headers.get('etag')).toBeDefined()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue