通过ENV传递监听地址

This commit is contained in:
CN-JS-HuiBai
2026-04-02 17:35:44 +08:00
parent aad2b3db89
commit 47de5ac65b
2 changed files with 4 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
PORT=3000
HOST=0.0.0.0
# AWS S3 / MinIO Configuration
AWS_REGION=us-east-1

View File

@@ -10,6 +10,7 @@ dotenv.config();
const app = express();
const PORT = process.env.PORT || 3000;
const HOST = process.env.HOST || process.env.LISTEN_ADDRESS || '0.0.0.0';
app.use(cors());
app.use(express.json());
@@ -145,6 +146,6 @@ app.get('/api/status', (req, res) => {
}
});
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
app.listen(PORT, HOST, () => {
console.log(`Server running on http://${HOST}:${PORT}`);
});