mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-05-09 16:35:53 +02:00
[GH-ISSUE #761] Image attachments from url won't get rendered in web ui #548
Labels
No labels
ai-generated
android-app
android-app
android-app
🪲 bug
build
build
dependencies
docs
enhancement
enhancement
🔥 HOT
in-progress 🏃
ios
prio:low
prio:low
pull-request
question
🔒 security
server
server
unified-push
web-app
website
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ntfy#548
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @codebude on GitHub (Jun 1, 2023).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/761
🐞 Describe the bug
Image/photo attachments from url are not loaded/previewed in web ui.
💻 Components impacted
web app
🔮 Additional context
Attachments, when send via the X-Attach header (=url) are not preview in the web ui. Same notification previews image on Android app. In Webbapp, just a file icon is shown.
In opposite, when the same file is send as local attachment, the image is shown in web ui (and in Android app).
Is this a bug or a feature?
@binwiederhier commented on GitHub (Jun 1, 2023):
This is a browser restriction. 99% of hosts won't allow rendering a URL from a different host due to CORS restrictions, so we don't even attempt it.
So it is not a feature or a bug. Ha.
@codebude commented on GitHub (Jun 1, 2023):
But doesn't CORS mainly relate to AJAX requests? If you load the preview via AJAX I understand the problem, but images doesn't have to be loaded via AJAX.
For example, something as follow should work (and bypass any CORS problems):
This should work, because the img-Tag doesn't care for CORS (at least that's my understanding/experience).
@binwiederhier commented on GitHub (Jun 2, 2023):
@codebude I would have bet good money on the fact that what you are saying is incorrect. But it seems to be true. This just blew my mind. 🤯 🤯 🤯
As for your suggestion. This will likely not work like this because for attachments that are not uploaded to the ntfy server, I do not have the content type.
External attachments look like this:
While uploaded ones look like this:
I don't want to have the server probe the URL, because there's a whole lot of security issues that come with that, so I'll have to figure something out in the browser. Let me see what I can do.
@binwiederhier commented on GitHub (Jun 2, 2023):
This is a PoC that works, but it flickers awkwardly. It assumes everything is an image and tries to load it as an
<img>tag, and then switches to the attachment box if it errors.I assume this can be "fixed" by storing the "is this an image" property locally in the indexedDB.
https://github.com/binwiederhier/ntfy/pull/763