XData Swagger UI not working behind IIS Reverse Proxy

We use an XData webservice hosted on internal network server (devserver).
We access the service through an IIS reverse proxy configured server, in order to resolve https certificates and connection.
See bvelow our rewrite rules, that work excelent on XData JSON service itself:

                <rule name="Redirect to https" enabled="True" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" negate="false" />
                    <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="off" />
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" />
                <rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                        <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
                        <set name="HTTP_ACCEPT_ENCODING" value="" />
                    <action type="Rewrite" url="http://devserver:2000/{R:1}" />
                <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" enabled="true">
                    <match filterByTags="A, Form, Img" pattern="^http://devserver:2000/(.*)" />
                    <action type="Rewrite" value="https{R:1}://noname.mydomain.ro/{R:2}" />
                <rule name="RestoreAcceptEncoding" preCondition="NeedsRestoringAcceptEncoding" enabled="true">
                    <match serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" />
                    <action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" />
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/(.+)" />
                    <preCondition name="NeedsRestoringAcceptEncoding">
                        <add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".+" />

But when we try to access swaggerui url of the service we receive the following message from swagger:

Failed to load API definition.

Fetch error

Failed to fetch http://devserver:2000/auth/openapi/swagger.json
Possible mixed-content issue? The page was loaded over https:// but a http:// URL was specified. Check that you are not attempting to load mixed content.

Is there a way we can configure our XData Swagger service to accept mixed content?


Please take a look at the Forward middleware: Middleware System | TMS Sparkle documentation.

We used:

procedure TServerContainer.XDataServerModuleCreate(Sender: TObject; Module: TXDataServerModule);
  Module.AccessControlAllowOrigin := '*';

Still same error:
Fetch errorFailed to fetch http://internalserver:2000/auth/openapi/swagger.json
Fetch errorPossible mixed-content issue? The page was loaded over https:// but a http:// URL was specified. Check that you are not attempting to load mixed content.

You have to check if IIS and/or your redirect is properly adding the HTTP headers so that Forward middleware can interpret it correctly.

Alternatively you can try to use OnGetAbsoluteUrl event: Swagger API service problem when using HTTPS URL - XData SwaggerUI - XDataServerModule - #16 by wlandgraf