twopluszero / next-images

Import images in Next.js (supports jpg, jpeg, svg, png and gif images)
MIT License
949 stars 67 forks source link

Redirects not working when using next-images #69

Open yesitsdave opened 3 years ago

yesitsdave commented 3 years ago

Using next 10.0.3, it seems that async redirects() in the config is ignored if using next-images.

Other config options work fine, but pages which should be redirecting just return 404. Removing next-images fixes the issue.

muditgoel01 commented 3 years ago

For redirects and rewrites to work properly in NextJs, you also need to ensure one more thing:

If you are using trailingSlash: true then your source paths must end with a slash.

{
    source: '/old/:id/',  // Notice the slash at the end
    destination: '/new/:id',
},

Any other plugins or configurations that interfere with routing also need to be taken into account.