I am working on a NextJs multi-domain website and need to fetch data based on the domain and device type. While I am able to identify the domain, I am looking to extract the user-agent in rewrite rules and utilize it within the getStaticProps function. Below are the rewrite rules specified 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',
},
],
};
},
Is there a way to capture the user-agent in the rewrite process, or do you have any alternative approach in mind? My goal is to differentiate between device types (mobile, tablet, or desktop) and dynamically render different content based on this information.