NextJs 重写产生 localhost redirected you too much times 错误

Lam*_*ina 1 javascript backend url-rewriting next.js

以下是我的next.config.js:

// next.config.js

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

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

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

有什么想法导致错误吗?

Lam*_*ina 5

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

// next.config.js

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