Skip to content

Commit

Permalink
Update bot detection list and add support for oxygen-do-not-stream-re…
Browse files Browse the repository at this point in the history
…sponse header
  • Loading branch information
blittle committed May 19, 2023
1 parent 25c4eec commit 37d9343
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-snails-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/hydrogen': patch
---

Update bot detection list and add support for oxygen-do-not-stream-response header
5 changes: 4 additions & 1 deletion packages/hydrogen/src/entry-server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ async function processRequest(
});
}

if (isBotUA(url, request.headers.get('user-agent'))) {
if (
request.headers.get('oxygen-do-not-stream-response') === 'true' ||
isBotUA(url, request.headers.get('user-agent'))
) {
response.doNotStream();
}

Expand Down
65 changes: 33 additions & 32 deletions packages/hydrogen/src/utilities/bot-ua.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,56 @@
* https://github.com/GoogleChrome/rendertron/blob/6f681688737846b28754fbfdf5db173846a826df/middleware/src/middleware.ts#L24-L41
*/
const botUserAgents = [
'AdsBot-Google',
'AdsBot-Google-Mobile',
'360spider',
'adsbot-google',
'adsbot-google-mobile',
'applebot',
'Baiduspider',
'baiduspider',
'Bytespider',
'360Spider',
'PetalBot',
'Yisouspider',
'baiduspider',
'bingbot',
'bingbot',
'Bingbot',
'BingPreview',
'bingpreview',
'bitlybot',
'Discordbot',
'DuckDuckBot',
'Embedly',
'bytespider',
'discordbot',
'duckduckbot',
'embedly',
'facebookcatalog',
'facebookexternalhit',
'Google-PageRenderer',
'Googlebot',
'Googlebot-Image',
'Googlebot-News',
'Googlebot-Video',
'google-inspectiontool',
'google-pagerenderer',
'googlebot',
'googlebot-image',
'googlebot-news',
'googlebot-video',
'googleother',
'googleweblight',
'ia_archive',
'LinkedInBot',
'Mediapartners-Google',
'ia_archiver',
'linkedinbot',
'mediapartners-google',
'outbrain',
'petalbot',
'pinterest',
'quora link preview',
'redditbot',
'rogerbot',
'seoradar',
'showyoubot',
'SkypeUriPreview',
'Slackbot',
'Slurp',
'skypeuripreview',
'slackbot',
'slurp',
'sogou',
'Storebot-Google',
'TelegramBot',
'storebot-google',
'telegrambot',
'tumblr',
'Twitterbot',
'vkShare',
'W3C_Validator',
'WhatsApp',
'twitterbot',
'vkshare',
'w3c html2txt',
'w3c_validator',
'whatsapp',
'yandex',

// SEO Tools
'Seoradar',
'W3C html2txt',
'yisouspider',
];

/**
Expand Down

0 comments on commit 37d9343

Please sign in to comment.