Servicestack Swagger UI端点与UseHttpsLinks的行为不符合预期

时间:2014-10-09 01:36:34

标签: ssl servicestack swagger-ui

使用4.0.31,我的AppHost配置方法声明如下:

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());

  ...
}

我的印象是,这会将swagger-ui的url设置为../api/resources的https版本,但是我仍然在swagger URL文本框中获取常规http端点,例如: / p>

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

我们的网络服务器支持执行SSL卸载(并且需要SSL)的负载均衡器,因此URL应为:

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

从积极的方面来说,使用'UseHttpsLinks'实际上允许swagger-ui在您修复端点网址后运行。没有它它根本不起作用!

我使用替换index.html通过Virtual File System作为黑客来覆盖swagger url属性 - 因为在开发,QA和登台环境中,url属性指向生产...... (不太好)

1 个答案:

答案 0 :(得分:1)

Config.UseHttpsLinks已扩展为也适用于BaseUrl,现在http://网址已更改为https:// in this commit

此更改可从 v4.0.33 + 获得,现在为available on MyGet