Azure / azure-functions-openapi-extension

This extension provides an Azure Functions app with Open API capability for better discoverability to consuming parties
https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.OpenApi/
MIT License
375 stars 196 forks source link

Support for X-Forwarded-Host #634

Open mathiasi opened 11 months ago

mathiasi commented 11 months ago

Describe the issue We have Function Apps that are accessed through a Front Door. This gives us some trouble with the URL in the swagger UI as the URL is being resolved to the direct URL of the Function App which is not what we want as it is not accessible and everything should go through the Front Door. Is there a way to configure the URL being set in the Swagger UI? As far as I can tell this is the logic that sets it and it doesn't appear there is a way to change it: https://github.com/Azure/azure-functions-openapi-extension/blob/ab184cbf3c8ff16378cfa00fa1cb23cb58ac1727/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/SwaggerUI.cs#L61

I know that the Front Door will send X-Forwarded-Host and X-Forwarded-Proto which we were able to use with older the older Swashbuckle library which we used for In-Process Function Apps.

To Reproduce Steps to reproduce the behavior:

  1. Deploy Function App
  2. Configure Front Door
  3. Try to access Swagger UI through Front Door
  4. Observe non-Front Door URL being used

Expected behavior Front Door URL should be used

Screenshots image

mathiasi commented 11 months ago

I realize that it is actually possible to change the value by manually specifying the server using the configuration. I'll leave this open for somebody else to judge if it is a good idea to support the header anyway. But I found a "workaround".

watfordsuzy commented 6 months ago

This is something we'd very much like in our scenario as well, mostly because of the layers of indirection coming to the function app. At the outermost you couldn't reach the UI, but at the function level you could (because we can't stop that with out-of-proc). We'd still like the UI to be accessible if possible at the function level with the correct URI.