We tried to run next export
command to generate static assets and to pack our app with cordova or capacitor. It turns out that those engines omit any folders that begin with an underscore without warning. And once you run next export
some of the files are put inside of _next
directory. So, to run the app one has to find a way to rename this folder and all links inside generated files not to include underscore.
It would be really nice to have an option available in next.config.js
to provide a name of that directory to be used instead of _next
.
We're not planning to allow changing the _next folder name as of currently.
@timneutkens any advices on how we can we wrap the app then?
@andrey-semin I handled this issue via Nginx Routing.
What i assumed while making this Nginx Routing is that every file will have unique hash and file name combination.
This is the snippet of code of Nginx Routing which i used.
location /static/ {
try_files $uri @server1;
}
location @server1{
proxy_pass http://192.168.1.1$uri;
proxy_intercept_errors on;
recursive_error_pages on;
error_page 404 = @server2;
}
location @server2{
proxy_pass http://192.168.1.2$uri;
proxy_intercept_errors on;
recursive_error_pages on;
error_page 404 = @server3;
}
location @server3{
proxy_pass http://192.168.1.3$uri;
}
What the above code does is, whenever Nginx encounters /_next/ it will first try that URL with @server1, if that Server responds with 404, the Nginx then transfers the request to @server2 as mentioned in error_page param.
This example works like:
try_files $uri @server1 @server2 @server3
This worked for me as i had 2 apps which were developed on Next and both has _next route.
Let me know if this solves your problem.
Hello,
I'm trying to figure out why but for the moment, deploying on gh-pages doesn't work well.
I succeeded to deploy my website, everything is quite ok but the folder _next
doesn't exist for the http server. It's here in the gh-pages branch in git, but no files available from the http server.
As they use by default jekyll, I'm pretty sure that any files named with _
as prefix are ignored.
So yeah, it could be great to be able to change this name.
I think I found the solution: https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/
I'm facing this issue currently as using nginx to micro frontends
@NimitMak what is your logic behind using three servers for this?
@kang-chen This was before we had basepath support from Nextjs, so we had 3 different apps running on next.js and each had _next folder, that's why we needed to add 3 different servers in the Nginx config which will check for respective files in each _next path, so that we don't encounter 404. Let me know if you need more details.