Skip to content
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

Copy to clipboard fails silently with macOS Safari when served remotely via http (not https) #282

Closed
DD-P opened this issue May 13, 2024 · 1 comment

Comments

@DD-P
Copy link

DD-P commented May 13, 2024

  1. OpenGist 1.7.2 via Ubuntu 23.10 containerised in Docker using the supplied docker-compose.yml.
  2. Clicking copy gist button does not place text on the clipboard

Results in TypeError: undefined is not an object (evaluating 'navigator.clipboard.writeText') in JavaScript console.

Explanation

This will work correctly over eg https://gist.homelab:6157 or http:https://localhost but not eg http:https://192.168.1.100:6157 or http:https://gist.homelab:6157

See https://webkit.org/blog/10855/async-clipboard-api/ which states —

The async clipboard API is a powerful web API, capable of both writing arbitrary data to the clipboard, as well as reading from the system clipboard. As such, there are serious security ramifications when allowing pages to write data to the clipboard

  • The API is limited to secure contexts, which means that navigator.clipboard is not present for http:https:// websites.

Workaround (Google Chrome)

  1. Allow-list your particular URL in Google Chrome via chrome:https://flags/#unsafely-treat-insecure-origin-as-secure in the Insecure origins treated as secure field.
  2. Access eg http:https://gist.homelab:6157 via Chrome
@thomiceli
Copy link
Owner

Not much to do from my side but this is good to know, maybe we should add this in the documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants