From 8cca071d9b7d8404dcf42c7ec6e4513b08d4950c Mon Sep 17 00:00:00 2001 From: abearxiong Date: Wed, 4 Jun 2025 15:22:57 +0800 Subject: [PATCH] fix: fix https config --- assistant/src/app.ts | 11 ++++++++++- assistant/src/server.ts | 3 ++- assistant/src/services/init/index.ts | 7 +++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/assistant/src/app.ts b/assistant/src/app.ts index 5fbf0ae..1c8ad6f 100644 --- a/assistant/src/app.ts +++ b/assistant/src/app.ts @@ -21,10 +21,19 @@ export const runtime = useContextKey('runtime', () => { type: 'client', }; }); + export const app = useContextKey('app', () => { const init = isInit; if (init) { - // const config = assistantConfig.getConfig(); + const config = assistantConfig.getConfig(); + if (config?.https?.type !== 'https') { + return new App({ + serverOptions: { + path: '/client/router', + httpType: 'http', + }, + }); + } } return new App({ serverOptions: { diff --git a/assistant/src/server.ts b/assistant/src/server.ts index e22d14d..c536bbc 100644 --- a/assistant/src/server.ts +++ b/assistant/src/server.ts @@ -32,7 +32,8 @@ export const runServer = async (port?: number, listenPath = '127.0.0.1') => { }); } else { app.listen(_port, listenPath, () => { - console.log(`Server is running on https://${listenPath}:${_port}`); + const protocol = assistantConfig.getHttps().protocol; + console.log(`Server is running on ${protocol}://${listenPath}:${_port}`); }); } app.server.on(proxyRoute); diff --git a/assistant/src/services/init/index.ts b/assistant/src/services/init/index.ts index a9c1e7a..894f8a5 100644 --- a/assistant/src/services/init/index.ts +++ b/assistant/src/services/init/index.ts @@ -140,4 +140,11 @@ export class AssistantInit extends AssistantConfig { }, } as AssistantConfigData; } + getHttps() { + const https = this.getConfig()?.https || {}; + return { + https, + protocol: https?.type === 'http' ? 'http' : 'https', + }; + } }