It had been working perfectly until I had to change to https. Here is my configuration for livereload:
const express = require("express");
const app = express();
const path = require('path');
const livereload = require('livereload')
const connectLiveReload = require('connect-livereload')
const liveReloadServer = livereload.createServer();
liveReloadServer.watch(publicDirectory)
liveReloadServer.server.once("connection",()=>{
setTimeout(() => {
liveReloadServer.refresh("/");
}, 200);
})
app.use(connectLiveReload());
The error it started displaying is:
And of course, it's not picking up on changes and reloading.
From the npm page of the package livereload here
Server API
The createServer() method accepts two arguments.
The first are some configuration options, passed as a JavaScript object:
- https is an optional object of options to be passed to https.createServer (if not provided, http.createServer is used instead)
You can check the NodeJS document about https.createServer here
From that, I think the configuration of liveReloadServer will be something like this, you use your SSL certificate and key :
const liveReloadServer = livereload.createServer({
https : {
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
}
});