@cocalc/hub
Version:
CoCalc: Backend webserver component
20 lines • 816 B
JavaScript
;
// The HTTP(S) server, which makes the other servers
// (websocket, proxy, and share) available on the network.
Object.defineProperty(exports, "__esModule", { value: true });
const logger_1 = require("../logger");
const http_1 = require("http");
const awaiting_1 = require("awaiting");
async function init(host) {
const winston = (0, logger_1.getLogger)("init-http-redirect");
winston.info(`Creating redirect http://${host} --> https://${host}`);
const httpServer = (0, http_1.createServer)((req, res) => {
res.writeHead(301, {
Location: "https://" + req.headers["host"] + req.url,
});
res.end();
});
await (0, awaiting_1.callback)(httpServer.listen.bind(httpServer), 80, host);
}
exports.default = init;
//# sourceMappingURL=http-redirect.js.map