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

protocol relative tile urls break file:// URLs #1729

Closed
pagameba opened this issue Feb 20, 2014 · 11 comments
Closed

protocol relative tile urls break file:// URLs #1729

pagameba opened this issue Feb 20, 2014 · 11 comments

Comments

@pagameba
Copy link
Member

In the developer's guide, we suggest to users that they can run the examples like this:

Then, either open one of the example html files from the examples directory directly in your browser, or start a simple web server, for example

The recent change to protocol relative urls in #1694, #1692, and #47 removes the ability to load HTML files with the file:// protocol. I suppose the easiest fix is to change that in the developer's guide, but I am not sure this is the best approach.

@elemoine
Copy link
Member

+1 for changing the developer guide.

@twpayne
Copy link
Contributor

twpayne commented Feb 20, 2014

Note that file:// URLs also don't play well with CORS, so I'm also +1 on changing the developer's guide.

@pagameba
Copy link
Member Author

#1741 might be a good reason to reconsider protocol relative urls in some cases.

@twpayne
Copy link
Contributor

twpayne commented Feb 21, 2014

There's an easy work-around for #1741 - see my comment in the issue.

@pagameba
Copy link
Member Author

Should the developer's guide could be updated with this advice for those wishing or needing to use the file:// protocol then?

@twpayne
Copy link
Contributor

twpayne commented Feb 21, 2014

It might make more sense to document it in the sources that use protocol-relative URLs.

@pagameba
Copy link
Member Author

How about in both places? Individual sources that use protocol-less URLs by default can mention it and what to use if the page is loaded from file:// and the developer's guide could include a note like this:

If you are loading your page using the file:// protocol instead of via a web server then you may need to set the url property of your source to set the protocol, see API documentation for the source you are using for more details.

Question: would setting the protocol in the source avoid CORS issues, or is this something that would still be a problem?

@twpayne
Copy link
Contributor

twpayne commented Feb 21, 2014

OK, makes sense.

As I understand it, CORS simply doesn't work over the file:// scheme.

@pagameba
Copy link
Member Author

Okay, put another way, what won't work because of CORS issues when using the file:// protocol? My poor recollection is that it was something to do with WebGL but ...

@twpayne
Copy link
Contributor

twpayne commented Mar 20, 2014

My understanding is that resources loaded from file:// do not have an origin set, and therefore cannot use CORS. I believe that this is related to security sandboxing, but do not know the full details.

@regevbr
Copy link

regevbr commented Dec 31, 2018

I overcame that issue by creating the following module - https://www.npmjs.com/package/cordova-network-interceptor which intercepts and fixes bad network requests caused by relative protocol used in scripts. Hope that helps!

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

4 participants