Search code examples
laravelvue.jsvagranthomestead

Nuxt.js + Vagrant + Homestead port forwarding


I am unable to connect to my Nuxt.js application OUTSIDE the vagrant box (aka. my host or local machine), but it's able to retrieve content INSIDE the vagrant box.

So...

I'm using Laravel Homestead to host my Nuxt.js application and I start the server inside the vagrant box by

nuxt start --public 0.0.0.0:3000

I can confirm that it's running and a message shows that it's listening to localhost:3000 and curl localhost:3000 returns the application content.

I have also checked my homestead.yaml config and I have port forwarding setup there.


ip: "192.168.10.10"
memory: 8192
cpus: 4
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: D:/Developments
      to: /home/vagrant/projects

sites:
    - map: homestead.test
      to: /home/vagrant/projects/public

databases:
    - homestead

ports:
    - send: 9200
      to: 9200
    - send: 5601
      to: 5601
    - send: 3000
      to: 3000  

What have I done wrong? other applications such as Elasticsearch and Kibana seems to run fine and can be accessed on my local/host machine.


Solution

  • I added this part to my package.json and now it's working

        "config": {
        "nuxt": {
          "host": "0.0.0.0",
          "port": "3000"
        }
      }