完成http、https修改

This commit is contained in:
2026-05-17 22:07:07 +08:00
parent 7ff53c2cfd
commit a8ceb194f6
5 changed files with 38 additions and 20 deletions

View File

@@ -14,10 +14,15 @@ import { log, LogLevel } from './log';
* @param config 配置选项
*/
export const initSwagger = (app: Express, config: Options): void => {
// 根据配置生成服务器URL
const protocol = config.secure ? 'https' : 'http';
const port = config.port || 8080;
const serverUrl = `${protocol}://localhost:${port}`;
const servers = [
{
url: serverUrl,
description: config.secure ? '本地HTTPS服务器' : '本地HTTP服务器'
}
];
/**
* Swagger配置选项
@@ -34,12 +39,7 @@ export const initSwagger = (app: Express, config: Options): void => {
email: 'contact@webrtc.example.com'
}
},
servers: [
{
url: serverUrl,
description: '本地开发服务器'
}
],
servers,
components: {
securitySchemes: {
sessionAuth: {