Running Babyon locally

Hi,
I tried running my babylon code with node js on a local server (and API emulator extension using galaxy s8 (AR)). However, I keep getting a warning “WebXR can only be served over HTTPS” when running with “http-server”. I noticed that I only have issues running with http when using immersive ar. I saw somewhere that it may be because using an async function? I tried doing the whole https thing with generating certificates and openssl but could not get it to work.

I used the playground as well and when I download anything from the playground and try to run the files locally I cannot see the same output as within the actual playground. If anyone has any suggestions for the best way to run playground samples/my own babylon code I would appreciate it!
Thank you

Adding @PirateJC for this one

1 Like

You know what, @jelster would probably have some wisdom to share on this topic as he’s writing a book that covers this very subject!

2 Likes

As you’ve noticed, WebXR requires an https connection. You mentioned that you’re using the http-server module, did you try the https-server Module as well?

I’m not as familiar with the node js http/s server, but the underlying principles should be the same - if you want you can post some details about your cert issue, generic advice:
Make sure you’re correctly reading/saving off your PK and such, certs can be tricky.

HTH

3 Likes

Thank you, I think my main issue is invoking the .html file (with the babylon code) in the .js file. I was able to use openssl and express and generate the certs, however I cannot link my html file properly.
Something like this
const app = express()

app.use(’/’,(req, res, next) => {

fs.readFile('./index.html', function read(err, data) {

Did you change your import to say https-server? When the server starts you should see output messages indicating that it has loaded the cert and is listening for https connections on the given port.

Also, make sure you’ve properly mapped your asset directories in express as static file mappings - with PG downloaded html counting as well - so that script references are properly resolved.

Finally, check to see that the html file doesn’t use http in the href or src attributes - best is to use the //

Yes thank you got it to work finally!
This was really helpful and I was able to run over https with node & express, had to make a few minor tweaks after to include my html. (used res.sendfile instead of readfile… How To Deliver HTML Files with Express | DigitalOcean)
https://www.youtube.com/watch?v=USrMdBF0zcg

2 Likes