【问题标题】:NextJs rewrites produce localhost redirected you too many times errorNextJs 重写产生 localhost redirected you too many times 错误
【发布时间】:2021-07-02 08:04:41
【问题描述】:

以下是我的next.config.js:

// next.config.js

module.exports = {
  async rewrites() {
    return [
      {
        source: '/results',
        destination: 'https://mywebsite.com/results',
      },
    ];
  },
};

根据Nextjs rewrites documentation (https://nextjs.org/docs/api-reference/next.config.js/rewrites#rewriting-to-an-external-url),访问https://nextjswebsite.com/results时,页面内容应改写为https://mywebsite.com/results的内容。

但是,我最终得到“本地主机重定向你太多次”。

任何想法是什么导致了错误?

【问题讨论】:

  • 您确定 destination 与您的 Next.js 应用 URL 不同吗?
  • @juliomalves 我在 nextJs 应用中只有一个主页,中间有一个大按钮,还没有创建其他页面

标签: javascript url-rewriting next.js backend


【解决方案1】:

所以显然我只需要在目的地有一个尾斜线

// next.config.js

module.exports = {
  async rewrites() {
    return [
      {
        source: '/results',
        destination: 'https://mywebsite.com/results/',
      },
    ];
  },
};

【讨论】:

    猜你喜欢
    • 2021-12-31
    • 2021-01-28
    • 1970-01-01
    • 2015-05-15
    • 1970-01-01
    • 2015-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多