首页 > 解决方案 > Nextjs`has`重定向在vercel中不起作用

问题描述

我正在将旧网站移至新网站,并尝试设置 301 重定向。我的旧网站 url 看起来像 /model?id=<uuid> ,新网站 url 看起来像 /model/<slug>. 所以我设置了如下重定向。

for(var item of events) {
        redirects.push({
            source: `/event`,
            has: [{
              type: 'query',
              key: 'id',
              value: item.id,
            }],
            destination: `/events/${item.slug}`,
            permanent: true,
        })
    }

当我在本地运行时,它运行良好。但在vercel中出现以下错误。

502: Bad Gateway
Code: TOO_MANY_FORKS

列出了大约 500 个重定向。

标签: next.jsvercel

解决方案


推荐阅读