That behavior is expected for specific paths, and it is driven by the "Content-Disposition" header, which is appended. There is a configuration mentioned in the link you shared to update it. Here are some references to help understand what's going on:
1. Adobe Community Link: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/apache-sling-content-disposition-filter/m-p/164687
2. Adobe Experience Manager Documentation: https://experienceleague.adobe.com/docs/experience-manager-65/administering/security/content-disposition-filter.html?lang=en
That being said, if you are asking how to deploy that configuration for another environment through code, please follow this link: https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/developing/basics/osgi-configurations.html?lang=en
If you are inquiring whether this is the correct approach, it will depend on your use case, but I think it's a valid solution. Just be aware of any potential security concerns.
Hope this helps.