Azure / Azure/azure-functions-openapi-extension
Base URL is incorrect when using with proxy
- Dominant language
- C#
- Stars
- 388
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the issue**
After enabling the proxies on V4 and adding the below proxy:
```
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"swagger": {
"matchCondition": {
"methods": [ "GET" ],
"route": "/"
},
"backendUri": "https://localhost/swagger/ui"
}
}
}
```
and opening the function from Visual Studio
`http://localhost:7071/swagger/ui` this works fine
`http://localhost:7071/` shows CORS errors:

After a quick investigation, I noticed that the URL passed to SwaggerUIBundle is wrong:
Here it is correct:

and when opening the root it is wrong:

Probably calculated here: https://github.com/Azure/azure-functions-openapi-extension/blob/main/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/SwaggerUI.cs#L61
I'll try to download the source code and debug it locally.
Contributor guide
Research direction
Start at src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/SwaggerUI.cs around line 61 and reproduce the proxy configuration with the root URL and /swagger/ui URL in Visual Studio. Compare the URL passed to SwaggerUIBundle in both cases; done means the root route produces the correct base URL and no CORS errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100