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 is sending request as `http` instead of `https` after upgrading `Swashbuckle.AspNetCore` nuget package to 5.6.0

See original GitHub issue

Hi,

I’m experiencing this issue after I upgraded the Swashbuckle.AspNetCore nuget package to 5.6.0 from 5.5.0. Swagger UI seems to be sending the request over http protocol instead of https, although the swagger page itself is hosted on https.

image

It throws TypeError: Failed to fetch.

The difference that I noticed on swagger page before and after upgrading the package is as below:

Before: image

After: image

Before upgrading the package, it didn’t have the servers array in the response which, I believe, might be related to the change that was released in 5.6.0:

Better support for reverse proxy environments, incl. assigning servers metadata based on the presence of common reverse proxy headers

Also, notice that the server url has the http scheme instead of https. Please let me know if there is any other information needed.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
alexrosenfeld10commented, Mar 29, 2021

I just added a

                options.PreSerializeFilters.Add((document, request) =>
                {
                    var scheme = request.Host.Host.StartsWith("localhost", StringComparison.OrdinalIgnoreCase)
                        ? "http"
                        : "https";
                    document.Servers = new[]
                    {
                        new OpenApiServer
                        {
                            Url = $"{scheme}://{request.Host}"
                        }
                    };
                });

to get around the issue

0reactions
cookiem3rcommented, Sep 21, 2021

Encountered the same issue on v6.2.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger UI page does not show when using Swashbuckle ...
Swagger UI page does not show when using Swashbuckle.AspNetCore for .net core web api stateless service in Azure Service Fabric #483.
Read more >
ASP.Net Core 3.1 Swagger Page Loads via HTTPS but Try ...
I just upgraded my project from Swashbuckle 5.6.3 to 6.0.7. I have made no code changes, but now when attempting to use the...
Read more >
Swashbuckle.AspNetCore.SwaggerUI 5.6.3
This package has at least one vulnerability with moderate severity. It may lead to specific problems in your project. Try updating the package...
Read more >
Get started with Swashbuckle and ASP.NET Core
Learn how to add Swashbuckle to your ASP.NET Core web API project to integrate the Swagger UI.
Read more >
Swashbuckle.AspNetCore.SwaggerUI 6.5.0
Middleware to expose an embedded version of the swagger-ui from an ASP.NET Core application.
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