reactjs - 如果没有 cookie,则 Next.js 重定向
问题描述
有没有办法仅在没有 cookie 的情况下将用户从结帐重定向到加入页面user_token
。Next.js 只允许设置字符串和 undefined as value
,但我需要验证没有 cookie:
redirects: async () => [
{
source: '/checkout',
has: [
{
type: 'cookie',
key: 'user_token',
value: '',
},
],
permanent: true,
destination: '/join',
},
],
我尝试将正则表达式用于空字符串,但它不起作用:
redirects: async () => [
{
source: '/checkout',
has: [
{
type: 'cookie',
key: 'user_token',
value: '(^$)',
},
],
permanent: true,
destination: '/join',
},
],
解决方案
推荐阅读
- excel - VBA 更改值,调用宏。忽视
- c# - 在 Visual Studio 中创建项目时如何自动添加其他库?
- php - 防止前端表单按钮重定向到 admin-post.php
- rust - 如何使用循环下降并插入 Rust 中的二叉树?
- c - 为什么我在 C 程序中没有得到正确的输出?
- ssl - cloudfare 上的 ssl 在浏览器上显示“您的连接不是私有的”
- xcode9.3 - OCLint Xcode 9.3.1 失败
- javascript - jQuery 事件委托行为
- jenkins - Jenkins groovy 管道发现价值
- python - 运行 tkinter+pymysql 脚本时出现 pymysql.err.ProgrammingError