inventree / InvenTree

Open Source Inventory Management System
https://docs.inventree.org
MIT License
4.32k stars 781 forks source link

Report setting for Inline PDF not working #8144

Closed LastEdit closed 1 month ago

LastEdit commented 1 month ago

Please verify that this bug has NOT been raised before.

Describe the bug*

I had enabled the user->report setting for inline report and label display and it was working previously. Recently I noticed it has starting downloading the files instead of showing in the browser from the server.

Happened on Firefox 129, 130

Steps to Reproduce

Enable inline setting. Generate report/label. PDF gets downloaded

Expected behaviour

Display PDF directly from server.

Deployment Method

Version Information

Version Information:

InvenTree-Version: 0.16.1 Django Version: 4.2.15 Commit Hash: 4c15e5c Commit Date: 2024-08-30

Please verify if you can reproduce this bug on the demo site.

Relevant log output

No response

SchrodingersGat commented 1 month ago

@LastEdit this is likely because we have changed the way that reports are generated. The report is saved on the server (in the /media/ directory) before download. This in turn means that the proxy server configuration is forcing a "download" attribute on the download file (if you are using our proxy server setup)

LastEdit commented 1 month ago

Thank you for the information, I didn't realize the proxy was impeding the setting from functioning.

I changed the Caddyfile to allow media/report/output to be inline and it has gone back to displaying inline. Are the only files placed in the report/output directory reports/labels generated from inventree itself? I saw the other threads about security for inline display. Should I be concerned if I allow the report/ouput folder to be displayed inline?

SchrodingersGat commented 1 month ago

@LastEdit our default behaviour (via the Caddyfile) is to be very conservative from a security POV. The danger is that an uploaded file may execute a script in the browser

LastEdit commented 1 month ago

Since the issue is caused by the default proxy configuration, and could be remedied by changing that configuration, I will close the issue.