最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - NextJs rewrites produce localhost redirected you too many times error - Stack Overflow

programmeradmin2浏览0评论

The following is my next.config.js:

// next.config.js

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

According to Nextjs rewrites documentation (.config.js/rewrites#rewriting-to-an-external-url), upon visiting , the contents of the page should be rewritten with contents of .

However, I end up getting "localhost redirected you too many times".

Any ideas what causes the error?

The following is my next.config.js:

// next.config.js

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

According to Nextjs rewrites documentation (https://nextjs/docs/api-reference/next.config.js/rewrites#rewriting-to-an-external-url), upon visiting https://nextjswebsite./results, the contents of the page should be rewritten with contents of https://mywebsite./results.

However, I end up getting "localhost redirected you too many times".

Any ideas what causes the error?

Share Improve this question edited Apr 6, 2021 at 14:48 juliomalves 50.6k23 gold badges178 silver badges169 bronze badges asked Apr 6, 2021 at 14:11 Lamis AbouzinaLamis Abouzina 4191 gold badge4 silver badges17 bronze badges 2
  • Are you sure the destination is different from your Next.js app URL? – juliomalves Commented Apr 6, 2021 at 14:51
  • @juliomalves i have nothing but a homepage at the nextJs app with one big button in the middle there's no other pages created yet – Lamis Abouzina Commented Apr 6, 2021 at 14:54
Add a ment  | 

1 Answer 1

Reset to default 6

so apparently i only needed a tailing slash at the destination

// next.config.js

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

评论列表(0)

  1. 暂无评论