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
1 Answer
Reset to default 6so apparently i only needed a tailing slash at the destination
// next.config.js
module.exports = {
async rewrites() {
return [
{
source: '/results',
destination: 'https://mywebsite./results/',
},
];
},
};