-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Improve FileProxy Handling, set Content-Type #30427
fix: Improve FileProxy Handling, set Content-Type #30427
Conversation
When proxying an asset file from Amazon S3 or Google Storage, we previously ignored important headers such as - Content-Type - Content-Length - Cache-Control We also ignored the storage service's HTTP response, effectively assuming 200, and just blindly passed on the content body. In the case of any errors or redirects, we would interpret that (empty or meaningless) body as the asset itself. Instead, we now proxy those HTTP headers and treat any non-200 as an error.
🦋 Changeset detectedLatest commit: 2f933d7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report
@@ Coverage Diff @@
## develop #30427 +/- ##
===========================================
- Coverage 51.29% 51.14% -0.16%
===========================================
Files 811 805 -6
Lines 15059 15074 +15
Branches 2751 2785 +34
===========================================
- Hits 7725 7709 -16
- Misses 6926 6931 +5
- Partials 408 434 +26
Flags with carried forward coverage won't be shown. Click here to find out more. |
…/mentionBot * 'develop' of github.com:RocketChat/Rocket.Chat: feat: add tooltip to badge mentions (#30590) chore: improve `Tag` a11y link (#30636) refactor: Replace `useForm` in favor of RHF on `AppInstallPage` (#30634) fix: Improve FileProxy Handling, set Content-Type (#30427) refactor: `EditRoomInfo` to typescript (#28318) fix: mobile ringing notification missing call id (#30614) fix: Some HTTP requests sent by apps don't have their data parsed into JSON (#30560) test: More tests for groups kick (#30536) fix: Threads breaking after sending messages too fast (#30622) chore: Remove text decoration from room tag (#30606) i18n: Language update from LingoHub 🤖 on 2023-10-10Z (#30613) fix: File attachments have no content when exporting room messages as file (#30596) fix: use setImmediate to handle username update (#30500) chore: `AnalyticsReports` visual adequacy (#30617)
Co-authored-by: Diego Sampaio <8591547+sampaiodiego@users.noreply.github.com>
When proxying an asset file from Amazon S3 or Google Storage, we previously failed to copy forward important headers such as
We also ignored the storage service's HTTP status response, effectively assuming 200, and just blindly passed on the content body. In the case of any errors or redirects, we would interpret that (empty or meaningless) body as the asset itself.
Instead, we now proxy those HTTP headers and treat any non-200 as an error.
Proposed changes (including videos or screenshots)
Content-Type
.Issue(s)
Fixes #18312 by proxying the Content-Type header
Steps to test or reproduce
Configure your RC installation to use Amazon S3 as the File Upload Storage Type.
Post a message in a chat room, along with an image attachment.
View the post with the image attachment.
Right-Click on the image and choose "Open Image in New Tab". (Wording is from Chrome. Other browsers will have the same functionality, albeit with different wording.)
Instead of an image, the browser will show text similar to:
Further comments
Content-Type
header when proxying from S3X-Content-Type-Options: nosniff
header (inapps/meteor/app/cors/server/cors.ts
)text/plain
)