I am trying to deploy a nuxt app to cpanel shared hosting. It is working fine on my local machine using run dev, build and start. However, when I moved the files to cpanel. I can run npm dev, build, and start. When I use npm run dev, an IP and port was generated, I visited this IP and port on my browser but its not working.
How can I make this IP work as well as make the app work with my domain.
for run nuxt ssr in cpanel you can use below code and install pm2 in your project:
1-package.json:
"config": {
"nuxt": {
"host": "0.0.0.0",
"port": "customport"
}
},
"scripts": {
"dev": "nuxt --host yourdomain --port customport",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"deploy": "/opt/cpanel/ea-nodejs10/bin/pm2 start /opt/cpanel/ea-nodejs10/bin/npm --name yourpm2name -- start"
},
2-.htaccess file
RewriteEngine On
RewriteCond %{SERVER_PORT} 443
RewriteRule ^index.php(.*) http://yourdomain::customport/$1 [P,L]
RewriteRule (.*) http://yourdomain:customport/$1 [P,L]
3- run this code: npm run build 4- and then: pm2 start yourpm2name