Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running svelte dev on server

I am running svelte like this on my server:

$ npm run dev


  Your application is ready~! šŸš€

  - Local:      http://localhost:5000

ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ LOGS ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€

Which is great. However, when I try to access through my public ip, the bundle is not found. I.E. When I type <publicIP>:5000 into the browser. It doesn't show up. The port is open and accessible. Is there any way to achieve this?

The request just fails. But shouldn't it work if it's running on localhost:5000? I have set up a node server and I can indeed access it on port 5000, but it doesn't serve the files properly like npm run dev does.

like image 760
Dara Java Avatar asked Aug 04 '20 21:08

Dara Java


1 Answers

Declare the environment variable HOST=0.0.0.0

HOST=0.0.0.0 npm run dev

inspiration / possible source: https://github.com/lukeed/sirv/issues/29#issuecomment-497907602


You can also modify the dev script in the package.json and prepend HOST=0.0.0.0

  "scripts": {
    "build": "rollup -c",
    "dev": "HOST=0.0.0.0 rollup -c -w",
    "start": "sirv public"
  },

And now you can simply run npm run dev

like image 192
Madacol Avatar answered Sep 27 '22 16:09

Madacol