wlandgraf
(Wagner Landgraf)
December 22, 2021, 3:42pm
2
Yes, the problem is that XData thinks your server is in port 80, that's why it provides the Swagger UI trying to get the json from port 80.
You can use Forward middleware (if your router provides the correct headers), or use OnGetAbsoluteUrl event to mannually provide the correct "public" URL for your Swagger endpoint.
More information here:
It really depend on how Cloudflare is sending the forward headers. Are you able to inspect the request headers from Cloudflare?
The forward middleware should solve it properly if the headers are "standard".
Have you also properly used the OnAcceptProxy to accept the CloudFlare proxy?
Finally, you can always use OnGetAbsoluteUrl event to go the brute force and change the URL manually (add the https): Swagger API service problem when using HTTPS URL - XData SwaggerUI - XDataServerModule - #16 b…
Are you able to debug your server? In XData.SwaggerUI.Service.Internal you can see this code:
SwaggerUrl := TXDataOperationContext.Current.Handler.AbsoluteUrl('openapi/swagger.json') + Query;
JS := SwaggerUICode;
JS := StringReplace(JS, '%URL%', SwaggerUrl, []);
You can see that the SwaggerUrl is provided via a construction using AbsoluteUrl method.
And AbsoluteUrl is this:
function TXDataRequestHandler.AbsoluteUrl(const RelativeUrl: string): string;
var
Scheme: string;
Authority: …