mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2026-04-03 02:53:16 +08:00
feat: 后端支持自定义 host 和 port. 环境变量 SUB_STORE_BACKEND_API_HOST 默认 ::, SUB_STORE_BACKEND_API_PORT 默认 3000
This commit is contained in:
8
backend/src/vendor/express.js
vendored
8
backend/src/vendor/express.js
vendored
@@ -1,8 +1,9 @@
|
||||
/* eslint-disable no-undef */
|
||||
import { ENV } from './open-api';
|
||||
|
||||
export default function express({ substore: $, port }) {
|
||||
export default function express({ substore: $, port, host }) {
|
||||
port = port || 3000;
|
||||
host = host || '::';
|
||||
const { isNode } = ENV();
|
||||
const DEFAULT_HEADERS = {
|
||||
'Content-Type': 'text/plain;charset=UTF-8',
|
||||
@@ -29,8 +30,9 @@ export default function express({ substore: $, port }) {
|
||||
|
||||
// adapter
|
||||
app.start = () => {
|
||||
app.listen(port, () => {
|
||||
$.info(`Express started on port: ${port}`);
|
||||
const listener = app.listen(port, host, () => {
|
||||
const { address, port } = listener.address();
|
||||
$.info(`Express started on ${address}:${port}`);
|
||||
});
|
||||
};
|
||||
return app;
|
||||
|
||||
Reference in New Issue
Block a user