Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to exclude the images directory in a redirect source in NextJS

I followed this tutorial which is perfect for my NextJS website.
The problem is my unsupported.html file has images in it. The images 404 because according to the redirects everything except unsupported.html will redirect (including the images).

So here is Chrome vs IE. So Chrome works because I manually went there and it won’t redirect anything because it’s not IE.

How can I add to this part source: '/:path((?!unsupported.html$).*)', to say don’t redirect unsupported.html AND anything in the /public/images/ folder?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks
This feels close

source: '/:path((?!unsupported.html|.*images*$).*)',

enter image description here
enter image description here

>Solution :

Does this work for your site?

source: '/:path((?!unsupported\.html$|images/).*)',

The key bit is dropping the $ anchor from after images, so it doesn’t have to (not) match the actual image name

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading