Ad

How To Set Up 2 Project Website In Nginx [im Using Nuxt Run Diffent Port]

- 1 answer

Here is my structure folder

  • var

    • www

      • html

        • backoffice

        • frontend

My projects are in backoffice and frontend

Im using pm2 to start my server port 3000, 3100

location / {
    proxy_pass http://localhost:3000;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection 'upgrade';
     proxy_set_header Host $host;
     proxy_cache_bypass $http_upgrade;
}

location /admin {
     proxy_pass http://localhost:3001/admin;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection 'upgrade';
     proxy_set_header Host $host;
     proxy_cache_bypass $http_upgrade;
}

the path / is fine . The problem is in my /admin It's turn into white screen

In nuxt when I npm run build It will compile into .nuxt folder

the problem are here when I run /admin path It run at port 3001

I try to debug by inspect element my js path

/_nuxt/921cc8ac0d041c1ae8a6.js

and when I click into link It's

/* script not found */

the problem are here I think It's run port 3000 in stead of 3100 that's why It cant read any Css in /admin or 3001 port

How can I fix this

Ad

Answer

I need to add this into my nuxt.config.js

router: {
  base: '/admin/'
}
Ad
source: stackoverflow.com
Ad