Since November 19, 2018, Function Compute adds content-disposition: attachment to the response header when a function is triggered by an HTTP trigger. This causes browsers to download the response as a file instead of rendering it inline.
Use one of the following methods to prevent the forced download.
Option 1: Use the test domain name (for quick testing)
Log in to the Function Compute console.
Go to the HTTP trigger details page for your function.
Click the test domain name to download and run the configuration script.
After running the script, access your function through the test domain name — the browser renders the response directly.
Option 2: Use a custom domain name (for production)
Bind a custom domain name to your function instead of using the default aliyuncs.com domain. Custom domain names are not subject to the forced-download restriction.
For setup instructions, see Configure a custom domain name.
Option 3: Set the Content-Type response header (for programmatic control)
Return content-type: text/html in your function's response header. When the browser receives this header, it renders the response as HTML instead of downloading it.
Set the response header in your function handler before returning the response:
Content-Type: text/htmlThis approach requires modifying your function code. Use it when you need fine-grained control over how different responses are rendered.