This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/server/no-ssr.js

22 lines
872 B
JavaScript

import isHighLoadTime from './overload';
const USER_AGENT_BOTS = /bot|crawler|baiduspider|80legs|ia_archiver|voyager|curl|wget|yahoo! slurp|mediapartners-google|facebookexternalhit|twitterbot|whatsapp|php|python|mastodon/;
const USER_AGENT_BROWSERS = /mozilla|msie|gecko|firefox|edge|opera|safari|netscape|konqueror|android/;
const isBrowser = (userAgent) => {
if (!userAgent) {
return false;
}
const isProbablyBot = !!userAgent.toLowerCase().match(USER_AGENT_BOTS);
const isProbablyBrowser = !!userAgent.toLowerCase().match(USER_AGENT_BROWSERS);
return isProbablyBrowser && !isProbablyBot;
}
export default function(req, res, next) {
// if (process.env.NODE_ENV === 'production' && !req.url.startsWith('/card/@')) {
// res.spa = isBrowser(req.headers['user-agent']) || isHighLoadTime(process.env.LOCALE);
// }
next();
}