David Montgomery
David Montgomery

Reputation: 1648

Servicestack Swagger UI endpoint not behaving as expected with UseHttpsLinks

Using 4.0.31, my AppHost Configure method is declared like this:

public override void Configure(Funq.Container container)
{
  HostConfig hc = new HostConfig() 
     { HandlerFactoryPath = "api", UseHttpsLinks = true };
  SetConfig(hc);
  Plugins.Add(new CorsFeature());
  Plugins.Add(new SwaggerFeature());

  ...
}

I was under the impression that this would set the url for swagger-ui to be the https version of ../api/resources, however I'm still getting the regular http endpoint in the swagger URL textbox, like:

http://example.com/myapp/api/resources

Our web servers are behind load-balancers that perform SSL offloading (and require SSL), so the URL should be:

https://example.com/myapp/api/resources

On a positive note, using 'UseHttpsLinks' actually allows swagger-ui to function once you fix the endpoint url. It didn't work at all without it!

I'm overriding the swagger url property using a replacement index.html via the Virtual File System as a hack -- since in the development, QA, and staging environments, the url property is pointing to production...(not so good)

Upvotes: 0

Views: 766

Answers (1)

mythz
mythz

Reputation: 143284

Config.UseHttpsLinks has been expanded to also apply to the BaseUrl where it now changes http:// urls to https:// in this commit.

This change is available from v4.0.33+ that's now available on MyGet.

Upvotes: 1

Related Questions