提交 3f782c92 authored 作者: Will Chen's avatar Will Chen

bind to localhost explicitly

上级 4fbf8ef6
...@@ -114,7 +114,6 @@ const handleRequest = (config) => async (req, res) => { ...@@ -114,7 +114,6 @@ const handleRequest = (config) => async (req, res) => {
let filePath = path.normalize( let filePath = path.normalize(
path.join(config.rootDir, parsedUrl.pathname) path.join(config.rootDir, parsedUrl.pathname)
); );
console.log(`filePath: ${filePath}`, "request", req.url);
// Handle root path or directory paths, serve index.html // Handle root path or directory paths, serve index.html
if (filePath === path.normalize(config.rootDir) || filePath.endsWith("/")) { if (filePath === path.normalize(config.rootDir) || filePath.endsWith("/")) {
...@@ -124,7 +123,6 @@ const handleRequest = (config) => async (req, res) => { ...@@ -124,7 +123,6 @@ const handleRequest = (config) => async (req, res) => {
// Check if file exists and get its stats // Check if file exists and get its stats
let stats; let stats;
try { try {
console.log(`filePath: ${filePath}`, "stats");
stats = await statAsync(filePath); stats = await statAsync(filePath);
} catch (error) { } catch (error) {
// File not found // File not found
...@@ -216,8 +214,8 @@ export const startServer = async (userConfig = {}) => { ...@@ -216,8 +214,8 @@ export const startServer = async (userConfig = {}) => {
console.error(`[Worker ${process.pid}] Server error:`, err); console.error(`[Worker ${process.pid}] Server error:`, err);
reject(err); // Reject promise on server error during startup reject(err); // Reject promise on server error during startup
}); });
console.log(`[Worker ${process.pid}] Listening on port ${config.port}`);
server.listen(config.port, () => { server.listen(config.port, "localhost", () => {
console.log( console.log(
`[Worker ${process.pid}] 🚀 Static file server running at http://localhost:${config.port}/` `[Worker ${process.pid}] 🚀 Static file server running at http://localhost:${config.port}/`
); );
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论