fix: 配置 Swagger UI 使用 CDN 资源
解决 Vercel serverless 环境中 SwaggerUIBundle 未定义的问题, 使用 jsDelivr CDN 加载 Swagger UI 静态资源。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a7c082a162
commit
0a7d6c16c9
12
api/index.ts
12
api/index.ts
|
|
@ -92,7 +92,17 @@ async function bootstrap() {
|
|||
.addBearerAuth()
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup('docs', app, document);
|
||||
|
||||
// 配置 Swagger UI 使用 CDN 资源(解决 serverless 环境静态资源问题)
|
||||
SwaggerModule.setup('docs', app, document, {
|
||||
customCssUrl: [
|
||||
'https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.11.0/swagger-ui.css',
|
||||
],
|
||||
customJs: [
|
||||
'https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.11.0/swagger-ui-bundle.js',
|
||||
'https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.11.0/swagger-ui-standalone-preset.js',
|
||||
],
|
||||
});
|
||||
|
||||
await app.init();
|
||||
cachedApp = expressApp;
|
||||
|
|
|
|||
Loading…
Reference in New Issue