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

should prefix.js fall back to https if loaded from file:// uri? #93

Closed
gardnerjr opened this issue Dec 11, 2015 · 4 comments
Closed

should prefix.js fall back to https if loaded from file:// uri? #93

gardnerjr opened this issue Dec 11, 2015 · 4 comments

Comments

@gardnerjr
Copy link

from this stack overflow: http://stackoverflow.com/questions/33952511/microsoft-application-insights-on-cordova-requests-goes-to-file/34230709#34230709

the default prefix/snippet doesn't specify a protocol, falling back to whatever the page got loaded from (presumably so http gets the ai script also via http, and https sites get the script via https so there's no "unsecure content" errors or warnings.

however, if you use the example from a file:// based source, like a cordova app in the stack overflow question above, it also tries to load / submit data to:

file:// dc.services.visualstudio.com/v2/track

instead of using https. should there be code in the snippet to fall back to https when sending data to DC even if the source was loaded from a file:// uri?

@MaxShehovtsov
Copy link
Contributor

@gardnerjr I don't see any issues of top of my head.
@scsouthw @olegsych - do you guys remember why we change DC url protocol based on page protocol?

@olegsych
Copy link
Member

The only reason I can think of is to ensure that an https page talks to AI over https (browsers can block https page talking to http resources). An http page could be more efficient in its bandwidth use if it used http to talk to AI as well, but it wouldn't be terrible if AI scripts could always used HTTPS.

@gardnerjr
Copy link
Author

i think right now you can repro this in a desktop webpage. create a "page.html" on your windows desktop. paste a valid snippet with a valid ikey into it. open it with the browser via file:\\c:\users\yourusername\desktop\page.html (or whatever you name it, etc). You won't see any outbound traffic to dc.

first, because the browser will fail to load the ai javascript from a file://uri.

Then, modify the snippet to use https:// to get the ai javascript.
refresh the browser. now the AI sdk will download just fine (as it is https instead of file, which doesn't exist), but you still won't see any outbound traffic to dc.

to fix it, you also have to add:

           endpointUrl: "https://dc.services.visualstudio.com/v2/track"

to your config, to force the sdk to send data with a proper protocol, as the ai sdk doesn't have one, it is just //dc.services... without a protocol in the downloaded ai.0.js. once you do the 2 steps above to explicitly specify a protocol, if you refresh the page, you'll see outbound network requests to dc.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants