skip to Main Content

I am new to nuxt and node technologies. I have an app that in addition to a vuejs frontend also uses an api backend to access a database.

It seems to me I understand how to generate the front end with

npx nuxi generate

and then upload the .output.public folder to a static domain.

But what to do with the api part that is located under the server directory?

At the moment I have only an embryo that is like this

server

    api
        person.get.ts
        person.post.ts
        person.put.ts
        person.delete.ts  
    routes
        (empty folder)
     

All this runs perfectly in the development environment.

In my hosting there is a cpanel with a node.js setup tool that requires the following information:
enter image description here

Application mode: dev or prod (this I understand)

Application root: the place where to upload my application files
This I am not sure to perfectly understand.
Should I upload here the content of the above server folder as is or should I run a npm command to prepare the stuff?

Application URL: the http/https link to the application
I understand where the domain points Probably needs an htaccess file.

Application startup file:
I cannot see what it is . The guide of the hosting gives server.js as example but I have no server.js file not even any .js file under the server directory

I hope I am clear enough to receive ad hoc help? Thank you in advance.

PS: I do not want to change of hosting provider thus please don’t suggest me other hosting solution.

2

Answers


  1. You need to run npm run build which will generate .output directory in your project folder. Then you take contents of this folder and upload them.

    .output
      - public
      - server
      - nitro.json
    

    Application startup file should be serverindex.mjs

    Login or Signup to reply.
  2. As Ellrohir explained, you will need a JS runtime to be able to run your application (this is for the backend part). You don’t need to separate the static part and the backend of your application, you can deploy your entire application together on your hosting

    To package your application you must run: npm run build

    You will get the directory: .output

    This directory contains your application (functional and ready to run on node.js). This directory you must place on your hosting

    Then to be able to run your application, you must configure the following command to your hosting: node .output/server/index.mjs

    Important: Remember that if you have environment variables, you must configure them on your hosting

    Ref. Documentation: Nuxt deployment

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search