Freddie
Freddie

Reputation: 11

Can a NuxtJs "universal" application be served from an apache server or does it need to be served via node?

I am wondering if Apache can be set up to run a NuxtJs "Universal" app. From looking at the documentation it seems the "SPA" version of the app is built into a dist directory that I know I can serve from apache without any problems. It also looks like the "Static" build can be served from apache as well. but the Nuxt documentation for deploying a universal app says • Upload the contents of your application to your server of choice. • Run nuxt build to build your application. • Run nuxt start to start your application and start accepting requests. I do not believe that Apache has any way of nuxt build or nuxt start which are node commands.

Upvotes: 1

Views: 667

Answers (1)

bar5um
bar5um

Reputation: 912

In case if anyone's struggling with this: You will have to have NPM (NodeJS) installed on your server. By the way you'll need SSH access to the server. Then should upload the whole project to the server. Say you want to run the project in Development environment. You should run npm run dev and since the default port in development environment is 3000 , your .htaccess file should be as follows:

RewriteEngine On
DirectoryIndex disabled

RewriteRule ^$ http://127.0.0.1:3000/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:3000/$1 [P,L]

Upvotes: 1

Related Questions