After build my NextJs application and run, it works well on apache using the follow .htaccess. However I'm having problem with dynamic routes (something like: posts/[id]), for these cases it is returning chunk erros.
RewriteEngine On
DirectoryIndex disabled
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ http://127.0.0.1:4001/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:4001/$1 [P,L]
Even when you use mod_rewrite for this you should still include a ProxyPassReverse directive.
from the Apache docs: