I want to know if it is possible to deploy Nuxt app on a shared hosting.
After running npm run build --spa it generated below file structure in the dist directory, but don't know how to go from here.
-
3I think it is as simple as copying content of dist folder to your host. Then try yourdomain.com/server 🤷Sølve– Sølve2018-10-23 21:13:56 +00:00Commented Oct 23, 2018 at 21:13
2 Answers
Here are some checklists to deploy your spa app on hosting.
Did you configured your nuxt app as spa? You have to set your nuxt application
spamode innuxt.config.js.- Reference: https://nuxtjs.org/api/configuration-mode/
Can you configure rewrite rule on your hosting? If you build your application via
build --spayou need to configure rewrite rule that rewrite all request intoindex.html. This is sample configuration on Firebase Hosting.{ "hosting": { "public": "dist", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [ { "source": "**", "destination": "/index.html" } ] } }If you can't configure rewrite rule on your hosting, then you can build your application via
generate.
All checklist passed, then just upload your dist directory on your hosting! That's all!
Comments
Upload whats inside the build which is dist/ folder to public folder or from where the shared hosting domain points to after generating the pages.
If you're just gonna use it statically I suggest you better use some advanced static pages hosting with many benefits such as free ssl, CDN support, and push to deploy. e.g netlify.com, zeit.co/now .
This would only take you few minutes of learning and huge benefits in a lifetime.