When you invoke an HTTP function through the default proxy URL, Function Compute passes the full URL path — including the /2016-08-15/proxy/<serviceName>/<functionName> prefix — into your container as the HTTP request path. If your container's routing code registers only a short path like /test, the full path won't match, and your function returns a 404.
For example, this route:
@app.route('/test', methods=['POST', 'GET'])
def test():won't match the request path /2016-08-15/proxy/CustomDemo/func-http/test that Function Compute sends to the container. The fix is either to change the URL you use to invoke the function, or to update the route in your code.
Solutions
Pick the approach that best fits your situation:
| Approach | Best for |
|---|---|
| Use the subdomain URL | Quickest fix; no code change required |
| Add the x-fc-invocation-target header | cURL-based testing without a custom domain |
| Bind a custom domain name | Production traffic; clean URLs |
| Update the route in your code | Keep using the default proxy URL; accept the full path in code |
Use the subdomain URL
Function Compute assigns a dedicated subdomain to each HTTP trigger. Requests sent to this subdomain are routed directly to your function — the prefix /2016-08-15/proxy/<serviceName>/<functionName> is not included in the path your container receives.
Subdomain URL format:
https://<subdomain>.<region_id>.fcapp.run/[action?queries]Example:
https://funcname-svcname-khljsjksld.cn-shanghai.fcapp.run/action?hello=worldTo find your subdomain, see Step 3: Test the function.
Add the x-fc-invocation-target header
Add the x-fc-invocation-target header to your cURL command. This tells Function Compute which service and function to invoke, and your container receives only /$path — not the full proxy prefix.
Command syntax:
curl -v -H "x-fc-invocation-target: 2016-08-15/proxy/$ServiceName/$functionName" \
https://<account_id>.<region_id>.fc.aliyuncs.com/$pathExample:
curl -v -H "x-fc-invocation-target: 2016-08-15/proxy/CustomDemo/func-http" \
https://164901546557****.cn-hangzhou.fc.aliyuncs.com/testBind a custom domain name
Bind a custom domain name to your function, then invoke the function through that domain. The path your container receives is whatever you configure in the route settings — no proxy prefix is included.
Command syntax:
curl -v https://example.com/$pathExample (domain: example.com, path: /test):
curl -v https://example.com/testReplace /$path with the path configured in the route settings when you bind the domain. For details, see Route matching rules.
For setup instructions, see Configure a custom domain name.
Update the route in your code
Register the full proxy path in your container's routing code, then redeploy the function.
Update the route from:
@app.route('/test', methods=['POST', 'GET'])
def test():To:
@app.route('/2016-08-15/proxy/CustomDemo/func-http/test', methods=['POST', 'GET'])
def test():After redeploying, invoke the function using the original default URL:
curl -v https://164901546557****.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/CustomDemo/func-http/testThe default proxy URL format is https://<account_id>.<region_id>.fc.aliyuncs.com/<version>/proxy/<serviceName>/<functionName>/<path>.