fix: fix https config
This commit is contained in:
		| @@ -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: { | ||||||
|   | |||||||
| @@ -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); | ||||||
|   | |||||||
| @@ -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', | ||||||
|  |     }; | ||||||
|  |   } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user