Get target route parameters when using proxies
See original GitHub issueInvestigative information
Please provide the following:
- Function App version: 2.0.12285
- Python worker version: 1.0.0b3
- Function name: test-list
Repro steps
- Create sample function based on source code below
- Hit API
/api/list_proxy/group_1/product_a?validate=true
- It should be routed to
/api/list/
Expected behavior
I expected to have route parameter from the target function and some additional information from source proxy in another property:
{
"route_params": {
"group": "group_1",
"product": "product_a"
},
"params": {
"validate": "true"
}
}
Actual behavior
Instead I have the route params from the original proxy:
{
"method": "POST",
"url": "http://localhost:7071/api/list/group_1/product_a?validate=true",
"headers": {
"connection": "keep-alive"
},
"route_params": {
"restOfPath": "group_1/product_a"
},
"params": {
"validate": "true"
},
"get_body": ""
}
Known workarounds
We will add logic to our Function App to reconstruct the route params by using the URL and route from function.json.
Related information
Provide any related information
- Sample source files
Source
## function.json
{
"scriptFile": "__init_py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "request",
"methods": [
"post"
],
"route": "list/{group}/{product}"
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
## proxies.json
{
"proxies": {
"internal-routing": {
"matchCondition": {
"route": "/api/list_proxy/{*restOfPath}"
},
"backendUri": "https://localhost/api/list/{restOfPath}"
},
}
}
## __init_py
def main(request: azure.functions.HttpRequest) -> azure.functions.HttpResponse:
route_params = {}
if hasattr(request, 'route_params'):
route_params = dict(request.route_params)
params = {}
if hasattr(request, 'params'):
params = dict(request.params)
headers = dict(request.headers)
return json.dumps({
'method': request.method,
'url': request.url,
'headers': headers,
'route_params': route_params,
'params': params,
'get_body': request.get_body().decode(),
})
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to map the target endpoint URL parameters to the proxy url
Hi created a spec and proxy as shown in the below code with the base path as /generate_otp and target endpoint as http://control.msg91.com....
Read more >Angular proxy config; proxying URL get parameters
For troubleshooting, I created a simple server with route handler for GET /address/cities and using your exact proxy configuration I got the ...
Read more >Using target proxies | Load Balancing - Google Cloud
Target proxies are referenced by one or more forwarding rules. Target proxies terminate connections from the client and creates new connections to the...
Read more >Understanding routes | Apigee Edge
Determining the URL of the API proxy endpoint; Determining the URL of the target endpoint. Direct URL; Single target; Conditional targets; Null route....
Read more >how to pass new parameters to initial request #256 - GitHub
I'm trying to use the proxyReqBodyDecorator you mentioned but the value is not actually getting added to the request body that goes out...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Cool! I was able to repo this issue on my own with a JS function, and setting the app setting AZURE_FUNCTION_PROXY_DISABLE_LOCAL_CALL to true restored the correct behavior.
We’re going to take a look at the root cause for this, but that app setting should mitigate the issue for the time being 🙂
Thanks @alexkarcher-msft and @eduardomourar for investigation. Closing this one and will track work item here: https://github.com/Azure/azure-functions-host/issues/3593