Ism*_*ael 5 reactjs next.js vercel
nextjs 页面/users/[userid]在 vercel 平台中构建时静态呈现。无论如何,是否可以根据用户代理(设备类型)通过 vercel 或 nextjs 上的某些配置来提供该页面的两个不同版本?(同时保持静态)
移动用户请求example.com/users/userid获取与桌面用户请求相同路径不同的静态页面。
目前,此功能不可用。不过,我们正在努力进行更新,以使其成为可能。
请继续关注 Vercel 平台和 Next.js 的更新。
编辑:现在可以通过使用“has”属性和“重写”来实现:
// next.config.js
module.exports = {
async rewrites() {
return {
beforeFiles: [
{
source: '/some-page',
destination: '/somewhere-else',
has: [{
type: 'header',
key: 'user-header',
value: 'insert-regex-here'
}],
},
],
// ...
}
},
}
Run Code Online (Sandbox Code Playgroud)
EDIT2:现在使用Edge Middleware变得更加容易
| 归档时间: |
|
| 查看次数: |
1297 次 |
| 最近记录: |