crafty
crafty

Reputation: 53

Issue loading assets from _next folder on cpanel

I am having a problem deploying my app on cpanel. I am running npm run build, then using the set up a node js app function on cpanel.

The html and images load well. My issue is with the css and the js. The url is checking in the _next/static folder which i cannot see any where. E.g

https://my.domain.com/_next/static/chunks/pages/_app-40f8c9c2573612e5.js (this is 404)

If i replace _next with .next and use the url on the browser, i can see the js. Like so

https://my.domain.com/.next/static/chunks/pages/_app-40f8c9c2573612e5.js

The issue only on cpanel not on local. Also even if i change the name of the distDir in config it still checks the static files on _next.

If i manually move the files inside ./next/static to a new folder _next/static. It works

Does anyone know what I am missing?

I have tried renaming the .next folder to _next, I have also tried changing the directory name

Upvotes: 0

Views: 144

Answers (1)

Alex K
Alex K

Reputation: 7217

What helped me is create/edit an .htaccess in the app folder, and just map all _next/static to .next/static:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule _next/static/(.*) .next/static/$1 [L]
</IfModule>

Upvotes: 0

Related Questions