Open prm3theus opened 4 years ago
This is due to the way the gateway loads archives under paths like /KEYHERE/file
, this breaks absolute URLs like /script.js
since this would be loading from the gateway instead of the archive.
If you can set up a wildcard DNS for your domain, you can use the --redirect
flag which will load archives as subdomains which should fix the issue of absolute URLs.
I don't know if any public gateways have this feature though. 😰
Yes, I need to update the code / docs to indicate that a DNS setup is necessary for basic functionality.
@RangerMauve Do you know how to set up DNS + (nginx || apache) to create the correct conditions? I can't get wildcard subdomain HTTPS certification to work, so I can't test and resolve the issue -- much less document the correct setup.
I had trouble getting SSL certificates working, but DNS was easy enough by setting an A record to *.example.com
to point to the gateway server. From there I had it working over HTTP since it was able to redirect. I think letsencrypt only supports certain DNS providers for wildcard registration, and I'm not sure if the one I'm using (namecheap) is supported.
I'm also using namecheap. If you can produce any manner of documentation to help produce testable conditions, I'd appreciate it.
The alternative is to re-scope the gateway to assert that it is not an application context, and thus that using it to share web apps is dangerous (which it is).
Here's how to set a wildcard domain: https://www.namecheap.com/support/knowledgebase/article.aspx/597/2237/how-can-i-set-up-a-catchall-wildcard-subdomain
Looks like this guide shows how to add wildcard certificates using letsencrypt and namecheap: https://medium.com/@cubxi/add-wildcard-lets-encrypt-certifications-with-namecheap-6a466df0886f
Seems like redirecting using wildcards in ngxin is pretty easy too: https://serverfault.com/questions/447258/redirect-wildcard-subdomains-to-https-nginx
I'm going to be heads down with some work stuff for the next couple of weeks so I probably won't be able to make much progress on getting it together, but I might be able to after that.
Though lately I've been working with the new hyperdrive/hyperswarm stuff with dat-sdk so I'm not sure how much time I can devote to the gateway until there's support for that stuff. 😅
I'll give it a try.
@RangerMauve I have a PR up that addresses this subdomain issue by adding a -D domain
flag, but I didn't write tests because I haven't yet figured out how to reproduce the appropriate conditions under a testing environment (because DNS).
The PR looks good IMO. :o I don't have the certificate stuff set up at the moment so I can't test ATM.
System: Ubuntu 18.04.4 LTS
Running a react example on localhost, bundled with browserify, deployed on dat. Attempting to retrieve that dat, but experience this error:
Uncaught SyntaxError: Unexpected token '<'
Opening up the file in the Application tab, I see the index.html inside the javascript bundle.js.
When I try this experiement with dat://beakerbrowser.com/docs, many of the files / assets do not load properly either.