user5417542
user5417542

Reputation: 3376

Access Vue Application on Webpack-Server in Vagrant

I set up a virtual machine with Vagrant, ubuntu xenial64, installed npm/nodejs and the vue-cli.

I scaffolded a webpack application with vue init webpack myproject. When I now run npm run devthe webpack server starts, but since it's inside the virtual machine I can't access the webpage on my PC.

I found out, that you can run webpack server with --host 0.0.0.0 but since the Vue-Cli generates the whole process, I wasn't able to figure out where I can add this parameter.

Or is there another solution?

Upvotes: 2

Views: 1546

Answers (1)

user5417542
user5417542

Reputation: 3376

Ok fixed it myself :). Just add this to your Vagrantfile:

config.vm.network :forwarded_port, guest: 8080, host: 80

So nothing to do with Webpack, just basic vagrant setup. This will forward the 8080 port to 80 port of your host machine. So you need to type localhost:80 in your browser to get to your application.

Upvotes: 1

Related Questions