This commit is contained in:
Zakhar
2026-08-21 17:52:45 +03:00
parent d801adccaa
commit acbb58eb0a
12 changed files with 2771 additions and 9 deletions
+19 -4
View File
@@ -1,8 +1,9 @@
/** @file site/dev-server.js */
const http = require('http');
const http = require('https');
const fs = require('fs');
const path = require('path');
const WebSocket = require('ws');
import { createHttpsDevServer } from 'easy-https';
const HTTP_PORT = 9876;
const WEBSOCKET_PORT = 9878;
@@ -60,7 +61,7 @@ function serveStaticPageIfExists(route, res) {
* @param {req} req
* @param {res} res
*/
const requestHandler = function (req, res) {
const requestHandler = async function (req, res) {
const method = req.method.toLowerCase();
if (method === 'get') {
// No need to ensure the route can't access other local files,
@@ -74,5 +75,19 @@ const requestHandler = function (req, res) {
res.end();
};
const server = http.createServer(requestHandler);
server.listen(HTTP_PORT);
// const server = http.createServer(requestHandler);
// server.listen(HTTP_PORT);
async function start() {
const server = await createHttpsDevServer(
requestHandler,
{
domain: 'local.hvatilo.ru',
port: HTTP_PORT,
subdomains: ['test'], // will add support for test.my-app.dev
openBrowser: true,
},
);
}
start();