Eliminating server.js with Next.js 9.5
Next.js 9.5 came out a week after releasing the 1.0 version of the Github Repository Template I have been building in this series. Next 9.5 includes a lot of great enhancements, but a key new feature was the rewrites config. With this feature, I hop...
hashnode.blainegarrett.com7 min read
Today I discovered that the "Rewrites for Static Files" section of this post is not necessary in the above case of robots.txt
When I migrated to the the version of Next.js that introduced the public folder, I simply wholesale moved the static folder into the public folder. However, Next.js will attempt to serve files from public folder at the root url of your application. As such, you simply need to move the favicon.ico and the robots.txt into the /public directory and not bother with the rewrites.
As an additional test, I added a file to the public directory that would conflict with one of my dynamic routes and Next catches it, which is pretty great.