NikolaySuslov / livecodingspace

LiveCoding.space
MIT License
27 stars 7 forks source link

Express IP binding issue? #3

Open lazydino opened 5 years ago

lazydino commented 5 years ago

Hi Nikolay,

There is a IP binding situation I could not figure out. The express server seems unable to serve from IP other than localhost? I am fine with http://localhost:3007, but was refuse of connections with url like "http://[myip]:3007" ? Chrome will even go and rewrite the URL as "https:[myip]:3007"? The older branch of lcs-v0.1 , which doesn't use express js, does not seem to have the problem.

I go and change index.js:84 to force it bind my IP like

var srv = ssl ? https.createServer( sslOptions, app ).listen( port, '192.168.1.84' ) : http.createServer( app ).listen( port, '192.168.1.84' );

It still does not work?

lazydino commented 5 years ago

Further investigation leads me to routing in index.html. Seems to have something to do with micro client side routing of page.js ? Is it possible to run livecodingspace on a LAN environment and have LAN nodes run browser for test?

NikolaySuslov commented 5 years ago

Hello Reggie,

Thanks for pointing to that, I have needed to write about this in documentation. It is caused by Gun DB (SEA) only, which heavily uses WebCrypto, that does not work without HTTPS. So, if URL is not localhost, it redirects to HTTPS. The best way to use on LAN is to generate self-signed certificate and run a server with it: node index.js -p 3007 -s -k ./certs/server-key.pem -c ./certs/server-crt.pem -t ./certs/ca-crt.pem -w cert_password

Best regards, Nikolay

lazydino commented 5 years ago

Hi Nikolay,

Do I need to run Gun DB storage in https? What about reflector? I am able to run some tests under all 3 server instances on HTTP localhost. So this won't actually work for Gun DB SEA and WebCrypto? If I have the main website tested in secured localhost, aren't the other two needs to be also in HTTPS to prevent browser complaining of 'mixed content'?

Thanks!