typicode / hotel

🏩 A simple process manager for developers. Start apps from your browser and access them using local domains

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

json-server over https with hotel

chanof opened this issue · comments

Hi! May i ask an help to archive json-server over https?
I can't find any doc about who could help, currently json-server run on port 3000,
I use apache with certBot https.
Gian
Thanks a lot!

you have to run json-server as a module. check out their documentation.
the only difference is you have to set the port base on the PORT enviroment variable in your script:

...
const server = jsonServer.create()
// ... 
const PORT = process.env.PORT || 3000
server.listen(PORT, () => {
  console.log(`Run Auth API Server on https://localhost:${PORT}/`)
})

and for adding the script in your terminal with:
hotel add 'node script.js' --port 3000
It will add your json-server script. if you have a package.json you may also run it using "npm start" script instead of using "node script.js"

then start the hotel as you know:
hotel start
then visit the hotel panel at http://localhost:2000 and start your mock server there.
To visit your mock server simple open http://localhost:3000/, if you are not happy with the address or the port number you have to config the browser to use hotel's proxy configuration: http://localhost:2000/proxy.pac
after setting it try "http(s)://name-of-your-script-in-the-panel.localhost"
be noted that ssl certification will not be valid! and browsers like chrome would show a warning about this.

also note that there is a log file for hotel itself at ~/.hotel/daemon.log, it could be useful to ensure the proxy is being called by the browser and other troubleshooting stuff.

Please help me how to set up https I made video how it looks in my config. I made like you wrote
But dont know how to set up this

http://localhost:2000/proxy.pac
after setting it try "http(s)://name-of-your-script-in-the-panel.localhost"

https://streamable.com/fghsn

same issue