question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swagger UI hosted on empty path does not work anymore

See original GitHub issue

Did you read the migration guide?

  • I have read the whole migration guide

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Potential Commit/PR that introduced the regression

No response

Versions

5.2.0 -> 6.0.4

Describe the regression

Before 6.0, using swagger-ui-express, it was possible to host the swagger UI on the base url of the NestJS service. Now, the swagger UI doesn’t load, rendering a white page, because requesting swagger-ui-init.js results in a 404.

It works if I pass another path to SwaggerModule.setup() (e.g., "api"). I’ve already tried passing "/", but that does not work either.

Minimum reproduction code

const config = new DocumentBuilder()
        .setTitle("foo")
        .setDescription("bar")
        .setVersion("1.0")
        .build();
    const document = SwaggerModule.createDocument(app, config);
    SwaggerModule.setup("", app, document);

Expected behavior

Visiting 127.0.0.1:3000 displays the Swagger UI.

Other

image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
LinusPhoenixcommented, Aug 1, 2022

I was just investigating how the paths are handled internally when you pass "" or "/" as the path into SwaggerModule and when I came here to type what I found I saw you already fixed it a couple minutes ago. Thanks for the quick response!

1reaction
flamewowcommented, Aug 1, 2022

@kamilmysliwiec resolved the issue, here’s the PR https://github.com/nestjs/swagger/pull/2013

P.S. there are bunch of adjustments to make sure it works on ‘/’ path under proxy (https://github.com/nestjs/swagger/issues/1965)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger UI Not Loading - Stack Overflow
Try to copy the /dist directory in vendor/swagger-api/swagger-ui inside your project. I'm not sure about the proper way, but I was facing ...
Read more >
NET Core 2.2 and Swagger UI is not Displaying After Publish
hi. I use ASP Core 2.2 my config endpoint: c.SwaggerEndpoint("/swagger/v1/swagger.json", "my api1"); Swagger works in locals.
Read more >
Fixing Swagger UI "Try it out" Functionality When Deployed in ...
The Swagger UI renders as what you would expect but you've noticed that the "Try it out" functionality doesn't work anymore and get...
Read more >
Swagger UI and no response problem - Google Groups
You received this message because you are subscribed to the Google Groups "Swagger" group. To unsubscribe from this group and stop receiving emails...
Read more >
Swagger UI page is blank on localhost IISExpress SSL URL
It is only the IISExpress SSL URL of 'https://localhost:44387/' that has the empty page. I have spent hours working on this issue with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found