What is the best place to redirect based on the user-agent while using ISR? #21413
-
Hi Next.js community I have a really, in my view, basic requirement: I want to redirect a browser to a different site by inspecting its user agent. (IE11 to a special page that tells people to use a proper browser). I have used (abused?) Is there a better way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
This nextjs blog post covers your IE11 case pretty much :) module.exports = {
async redirects() {
return [
{
source: '/:path((?!old-browser$).*)',
has: [
{
type: 'header',
key: 'User-Agent',
value:
'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; Microsoft; Lumia 950)'
}
],
destination: '/old-browser',
permanent: false
}
]
}
} |
Beta Was this translation helpful? Give feedback.
This nextjs blog post covers your IE11 case pretty much :)
https://nextjs.org/blog/next-10-2#routing-based-on-headers-and-query-string-parameters