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

Bookmarklet doesn't work on docker #186

Open
jacob2020baklas opened this issue Jan 25, 2024 · 4 comments
Open

Bookmarklet doesn't work on docker #186

jacob2020baklas opened this issue Jan 25, 2024 · 4 comments

Comments

@jacob2020baklas
Copy link

jacob2020baklas commented Jan 25, 2024

the bookmarklet produced http request does't go past the browser
image

i think it needs ssl support
now it uses vpn and im not sure how to configure it behind my proxy
PS: everything else works as expected (UI & Download)

@jacob2020baklas
Copy link
Author

Update :
i modified the CMD which starts the unicorn server and rerun the container with docker compose

@manbearwiz
Copy link
Owner

yeah its been a long time since I tried the bookmarklet... I don't think adding the CORS middleware to starlette will fix that issue. I think adding that middleware would just allow you to load resources from other domains when on the youtube-dl ui. You might just need to use one of the browser extensions that let you toggle CORS on a page.

@manbearwiz
Copy link
Owner

@downtime0
Copy link

downtime0 commented Mar 5, 2025

I'm happily using the Bookmarklet in Firefox (135.0) pointing to a docker container but I had to resolve two CORS issues and make a minor change to the javascript where I had to make a change to an Asynchronous call:

javascript:(async function(){await fetch("https://ytdownload.example.net/youtube-dl/q", {body: new URLSearchParams({url: window.location.href, format: "bestvideo"}),method: "POST"});})();

I use Nginx Proxy Manager (as reverse proxy) and the first CORS issue was that modern browsers don't like HTTP unencrypted traffic so I had to get an SSL cert (LetsEncrypt) and stop using just the IP address to my docker host and container port.

Then the second CORS issue revealed itself, that I believe is related to this issue. I was able to resolve this CORS issue (Cross Origin Request) by adding a custom HEADER tag to the reverse proxy traffic request.
Add this to the Advanced Tab under Proxy Host configuration:

location / {
    proxy_pass http://<forwarded-ip>:<port>;
    add_header Access-Control-Allow-Origin "*";
    add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
    add_header Access-Control-Allow-Headers "*";
}

(Of course change the <forward-ip> and <port> values to your docker IP and container port)
This allows Cross-Origin POST requests from the Bookmarklet button to the FQDN endpoint using SSL.

This should only be considered a workaround. I do believe this HEADER tag (add_header Access-Control-Allow-Origin "*";) can be added to the source codes HEADER definition. And at the very least offered as a Docker environment variable to toggle on or off.

I hope someone finds this helpful. My cloned version is 2.0.0.

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

3 participants