I found that the protocol handler implementation blocks any requests for third-party origins. For my use-case I would like these resources to load as they would do on the web.
After a bit of digging I found that by changing the ProtocolHandler's protocolFlags then cross origin requests will load (see this commit). Changing the URI_LOADABLE_BY_SUBSUMERS flag to URI_LOADABLE_BY_ANYONE allows third-party scripts and images to load, but blocks cross-origin fetch (see nsiProtocolHandler docs for flag descriptions). I am not sure if there are any other implications of this change on security however.
This change also fixes links to urls with this protocol from pages on other protocols (e.g. http). With the current flags, a dat:// link like those on https://hashbase.io/pfrazee/rss-reader-pfrazee do not work.
https://github.com/sammacbeth/libdweb/blob/c8aaf40285a6fa5ed6f0f2bf3a0e6de8726ef6f6/src/protocol/router.js#L452-L460
Depending on use-cases this behaviour may be preferable, or perhaps could be configurable in the API. If cross-origin support is desired as the default, I can make a PR from my branch.
I found that the protocol handler implementation blocks any requests for third-party origins. For my use-case I would like these resources to load as they would do on the web.
After a bit of digging I found that by changing the
ProtocolHandler'sprotocolFlagsthen cross origin requests will load (see this commit). Changing theURI_LOADABLE_BY_SUBSUMERSflag toURI_LOADABLE_BY_ANYONEallows third-party scripts and images to load, but blocks cross-origin fetch (see nsiProtocolHandler docs for flag descriptions). I am not sure if there are any other implications of this change on security however.This change also fixes links to urls with this protocol from pages on other protocols (e.g. http). With the current flags, a
dat://link like those on https://hashbase.io/pfrazee/rss-reader-pfrazee do not work.https://github.com/sammacbeth/libdweb/blob/c8aaf40285a6fa5ed6f0f2bf3a0e6de8726ef6f6/src/protocol/router.js#L452-L460
Depending on use-cases this behaviour may be preferable, or perhaps could be configurable in the API. If cross-origin support is desired as the default, I can make a PR from my branch.