You*_*ass 7 css express swagger-ui nestjs nestjs-swagger
我正在开发一个 Nestjs 项目,我添加了 swagger 来显示我的端点,它在开发模式下工作得很好,但是一旦使用https://zeit.co/(现在)部署在生产中,端点页面就无法正确显示(缺少 css),我在网络选项卡中收到此错误:
/favicon-32x32.png:1 Failed to load resource: the server responded with a status of 404 ()
/favicon-16x16.png:1 Failed to load resource: the server responded with a status of 404 ()
swagger-ui.css:1 Failed to load resource: the server responded with a status of 404 ()
Run Code Online (Sandbox Code Playgroud)
https://i.stack.imgur.com/T9IQv.png
谢谢。
小智 2
您需要在SwaggerModule.setup方法中提供其他选项:
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
// some code...
const options = new DocumentBuilder()
.setTitle('Your title')
.setDescription('Your description')
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document, {
customCssUrl: 'https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.15.5/swagger-ui.min.css',
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3568 次 |
| 最近记录: |