I have a multi-domain website in NextJs. I want to fetch data based on domain and device type. Now I can recognize the domain but I want to have the user-agent in rewrites rules and use it in the getStaticProps function. Here are my rules in the next.config.js file.
async rewrites() {
return {
afterFiles: [
{
has: [
{
type: 'host',
value: '(?<host>.*)',
},
{
type: 'header',
key: 'User-Agent',
value: '(?<ua>.*)',
},
],
source: '/',
destination: '/organizations/:host?ua=:ua',
},
],
};
},
Do you know how to catch user-agent in the rewrite? or do you have any other solution? I want to recognize device types (mobile, tablet, or desktop) and render different DOM based on them.