support http and https
This commit is contained in:
parent
034f2c6dcb
commit
0fb6c098d7
@ -1,7 +1,8 @@
|
||||
/* eslint-disable no-undef */
|
||||
|
||||
function setupLiveReload(): void {
|
||||
const ws = new WebSocket("wss://localhost:8080/ws");
|
||||
const protocol = window.location.protocol === "http:" ? "ws:" : "wss:";
|
||||
const ws = new WebSocket(`${protocol}://localhost:8080/ws`);
|
||||
|
||||
ws.addEventListener("message", (message) => {
|
||||
try {
|
||||
|
@ -2,6 +2,7 @@ import { Logger } from "@gnu-taler/taler-util";
|
||||
import chokidar from "chokidar";
|
||||
import express from "express";
|
||||
import https from "https";
|
||||
import http from "http";
|
||||
import { parse } from "url";
|
||||
import WebSocket from "ws";
|
||||
|
||||
@ -30,6 +31,7 @@ export async function serve(opts: {
|
||||
port: number;
|
||||
source?: string;
|
||||
development?: boolean;
|
||||
insecure?: boolean;
|
||||
examplesLocationJs?: string;
|
||||
examplesLocationCss?: string;
|
||||
onUpdate?: () => Promise<void>;
|
||||
@ -37,7 +39,9 @@ export async function serve(opts: {
|
||||
const app = express();
|
||||
|
||||
app.use(PATHS.APP, express.static(opts.folder));
|
||||
const server = https.createServer(httpServerOptions, app);
|
||||
const server = opts.insecure
|
||||
? http.createServer(app)
|
||||
: https.createServer(httpServerOptions, app);
|
||||
logger.info(`serving ${opts.folder} on ${opts.port}`);
|
||||
logger.info(` ${PATHS.APP}: application`);
|
||||
logger.info(` ${PATHS.EXAMPLE}: examples`);
|
||||
|
Loading…
Reference in New Issue
Block a user