fix: fix https config

This commit is contained in:
熊潇 2025-06-04 15:22:57 +08:00
parent c1388118a6
commit 8cca071d9b
3 changed files with 19 additions and 2 deletions

View File

@ -21,10 +21,19 @@ export const runtime = useContextKey('runtime', () => {
type: 'client', type: 'client',
}; };
}); });
export const app = useContextKey('app', () => { export const app = useContextKey('app', () => {
const init = isInit; const init = isInit;
if (init) { 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({ return new App({
serverOptions: { serverOptions: {

View File

@ -32,7 +32,8 @@ export const runServer = async (port?: number, listenPath = '127.0.0.1') => {
}); });
} else { } else {
app.listen(_port, listenPath, () => { 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); app.server.on(proxyRoute);

View File

@ -140,4 +140,11 @@ export class AssistantInit extends AssistantConfig {
}, },
} as AssistantConfigData; } as AssistantConfigData;
} }
getHttps() {
const https = this.getConfig()?.https || {};
return {
https,
protocol: https?.type === 'http' ? 'http' : 'https',
};
}
} }