farm-fe / farm

Extremely fast Vite-compatible web build tool written in Rust
https://farmfe.org
MIT License
4.97k stars 165 forks source link

[Bug Report]: Nestjs Swagger don't render the page #1709

Open Altro31 opened 2 months ago

Altro31 commented 2 months ago

Steps to reproduce

  1. bun run dev
  2. open the browser and navigate to localhost:3000/api

Reproduce link

https://github.com/Altro31/farm-swagger.git

What is actually happening?

the swagger page don't get rendered

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (4) x64 AMD Athlon 200GE with Radeon Vega Graphics
    Memory: 10.47 GB / 21.92 GB
  Binaries:
    Node: 22.0.0 - D:\Dev\nodejs\node.EXE
    npm: 10.6.0 - D:\Dev\nodejs\npm.CMD
    pnpm: 8.14.1 - ~\AppData\Local\pnpm\pnpm.CMD
    bun: 1.1.21 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @farmfe/core: ^1.3.12 => 1.3.12
shulandmimi commented 2 months ago

This is because @nestjs/swagger does not directly set the static resources related to swagger-ui-dist, but obtains them through the request path, but I did not see it in the @nestjs/swagger related tutorials, so this should be a feature (function) corresponding to some builder development, but we do not support this feature. You can temporarily avoid it in the following way. We will try to find a way to solve it later.

import * as express from 'express';

// ...
app.use(
    '/api',
    express.static(
      path.join(process.cwd(), 'node_modules', 'swagger-ui-dist'),
      {},
    ),
  );