Azure / Azure/azure-functions-host
golang customHandler HTTP redirect not sent back to client
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
Using Function App in Azure to develop a REST API. We are using golang for the REST API server.
Our function app is using enableForwardingHttpRequest set to "true", so that there is no need to have Function App specific changes or handling to the REST API.
All was working well until we attempted to HTTP redirect (302) in the responses.
Instead of the 302 responses to be sent back to the client, got either 404 or 500 responses. Have no logs to confirm, but suspecting that the redirect was being handled by the Functions Host Http Handler that is receiving the 302 and attempting to redirect. And the originating HTTP client would get a 404 or 500 from the function app, depending on the Location that was being used in the response.
Looked into the Functions Host code in this repo and did not see any setting to false of AllowAutoRedirect property. Suspecting this might be the problem.
Opened this question in Microsoft QA forum related to Function Apps
https://docs.microsoft.com/en-us/answers/questions/369932/azure-function-golang-customhandler-http-redirect.html
and got feedback from Pramod Valavala (Community Expert), that it probably is a Functions Host issue, he agreed with my assessment that HttpClientHandler is the most cause as he noted that the AllowAutoRedirect was not specifically set to false and is having the default true value.
Pramod suggested a workaround to disable enableForwardingHttpRequest. I did not yet attempt the workaround, and I suspect that it will resolve the issue. Still I would rather not turn off the enableForwardingHttpRequest feature.
Contributor guide
Research direction
Start by tracing enableForwardingHttpRequest through the Functions Host HTTP handling and inspect where HttpClientHandler.AllowAutoRedirect is configured; the issue names no file or test. Reproduce a Go custom-handler 302 response with forwarding enabled, compare the 404/500 behavior, and consider the work complete when the original redirect reaches the client without disabling forwarding.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, go
- Domain
- api, backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100