Skip to content

swagger path gets doubled when path set to 'api-docs' #15878

@milo-v

Description

@milo-v

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I was following this guide to setup swagger ui: https://docs.nestjs.com/openapi/introduction

However, when I set the path in SwaggerModule.setup to 'api-docs', I see the browser looks for assets in (for example) http://localhost:8000/api-docs/api-docs/swagger-ui.css. It is incorrect path and returns 404 not found.

It does not happen when I set any other value, for example, 'docs' gives me http://localhost:8000/docs/swagger-ui.css, which is the correct behavior.

Minimum reproduction code

https://docs.nestjs.com/openapi/introduction

Steps to reproduce

No response

Expected behavior

'api-docs' should not be duplicated

NestJS version

11.0.1

Packages versions

[System Information]
OS Version : Linux6.14.0-33-generic
NodeJS Version : v24.9.0
(node:17880) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use node --trace-deprecation ... to show where the warning was created)
PNPM Version : 10.18.0

[Nest CLI]
Nest CLI Version : 11.0.10

[Nest Platform Information]
platform-express version : 11.1.8
schematics version : 11.0.9
swagger version : 11.2.1
testing version : 11.1.8
common version : 11.1.8
config version : 4.0.2
core version : 11.1.8
cli version : 11.0.10

Node.js version

24.9.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue has not been looked into

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions