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

Support http .torrent urls in browser #208

Closed
phambanhan opened this issue Dec 16, 2014 · 6 comments
Closed

Support http .torrent urls in browser #208

phambanhan opened this issue Dec 16, 2014 · 6 comments

Comments

@phambanhan
Copy link

@phambanhan phambanhan commented Dec 16, 2014

I got error "Uncaught Error: invalid torrent id" with webtorrent in the browser (use webtorrent.min.js). This is my simple code:

var client = new WebTorrent();
var magnet_uri = '';
client.download(magnet_uri, function (torrent) {
console.log('Torrent info hash:', torrent.infoHash)
});

Please help me fix the error

Thanks

@feross feross changed the title Uncaught Error: invalid torrent id Support http .torrent urls in browser Dec 16, 2014
@feross feross added the area/browser label Dec 16, 2014
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 16, 2014

http .torrent urls are not supported in the browser yet. I changed the title of this issue to reflect the real problem.

Also, worth nothing that:

Until BitTorrent clients support WebTorrent, "pure" WebTorrent clients can only download from other WebTorrent clients.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 16, 2014

On second thought, I don't want to support http .torrent urls in the browser.

Most .torrent files are going to be hosted on servers that don't set the correct cross-origin resource header (Access-Control-Allow-Origin). So, the XHR request to load the .torrent file will always fail. This is true of the .torrent file you were trying to load.

If the site actually does support CORS, then you can simply fetch it yourself and pass the blob/buffer into client.download and it'll use the .torrent file.

@feross feross closed this Dec 16, 2014
@Wingman4l7

This comment has been minimized.

Copy link

@Wingman4l7 Wingman4l7 commented Jun 3, 2015

Unless I'm misunderstanding, CORS shouldn't be an issue if you're trying to make an XHR request to load a .torrent from the current domain, which you might be doing if you were using webtorrent as part of a browser extension.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Jun 6, 2015

@Wingman4l7 You're right. Is this an important feature to you?

@Wingman4l7

This comment has been minimized.

Copy link

@Wingman4l7 Wingman4l7 commented Jun 11, 2015

@feross Definitely! It's a crucial feature in using webtorrent as part of a browser extension. Of course, so is webtorrent using TCP / UDP within the browser, which is currently only does in nodejs... but that's another problem. :P

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Jun 12, 2015

Okay, PR welcome!

@feross feross closed this Jun 30, 2015
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.