简体   繁体   English

https 使用代理 OWIN 自托管 Web API 的 Swashbuckle 方案问题

[英]https scheme issue with Swashbuckle using Proxied OWIN self-hosted Web API

I have been working on a web api in C# using the self-hosted owin web api which is proxied. I have been working on a web api in C# using the self-hosted owin web api which is proxied.

I have setup the Swashbuckle.Core package, It all works fine.我已经设置了 Swashbuckle.Core package,一切正常。 I am just having one slight issue with the base url.我只是对基础 url 有一个小问题。

When I go to my swagger ui docs page, it loads fine, But it tries to get https://api.domain.com:80/ instead of https://api.domain.com/ and the site says " Can't read from server. It may not have the appropriate access-control-origin settings. ". When I go to my swagger ui docs page, it loads fine, But it tries to get https://api.domain.com:80/ instead of https://api.domain.com/ and the site says " Can't read from server. It may not have the appropriate access-control-origin settings. "。

Here is my code that enables SwaggerUI:这是我启用 SwaggerUI 的代码:

configSwag.EnableSwagger("docs/{apiVersion}/swagger", c =>
{
    var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
    var commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".XML";
    var commentsFile = Path.Combine(baseDirectory, commentsFileName);

    c.Schemes(new string[]
    {
        "https"
    });

    c.SingleApiVersion("v1", "MechaChat v1 Docs");
    c.IncludeXmlComments(commentsFile);
    c.PrettyPrint();
}).EnableSwaggerUi("v1/docs/{*assetPath}", c =>
{
    c.DocExpansion(DocExpansion.List);
    c.SupportedSubmitMethods("GET", "POST");
});

What would I need to do for the docs to get https://api.domain.com/ instead of https://api.domain.com:80/ ?我需要做什么才能让文档获得https://api.domain.com/而不是https://api.domain.com:80/

I ended up using NSwag, Seems to be working perfectly fine now!我最终使用了 NSwag,现在似乎工作得很好!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM