segmentio / analytics.js-core

The hassle-free way to integrate analytics into any web application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

amplitude does not load

zowers opened this issue · comments

we load scripts with crossOrigin="anonymous" as described in requirejs/requirejs#687

    var requirejs_createNode = requirejs.createNode;
    requirejs.createNode = function createNodeAddCors( config, moduleName, url ) {
        var node = requirejs_createNode(config, moduleName, url);
        node.crossOrigin = "anonymous";
        return node;

But the https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-2.4.1-min.gz.js does not load

Script from origin 'https://d24n15hnbwhuhn.cloudfront.net' has been blocked from loading by Cross-Origin Resource Sharing policy:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://our-server.com' is therefore not allowed access.

Please avoid using global window.require or ensure the integration works with crossOrigin="anonymous"
crossposting from segmentio/analytics.js#487

commented

Closed for inactivity/irrelevance. Please reopen if it's still an issue!

oh, that's nice
the issue is still present, we have to work it around

    var requirejs_createNode = requirejs.createNode;
    requirejs.createNode = function createNodeAddCors( config, moduleName, url ) {
        var node = requirejs_createNode(config, moduleName, url);
        if (url.indexOf("{{ scriptsRoot }}") == 0)
                node.crossOrigin = "anonymous";

        return node;
commented

segmentio/analytics.js#487 (comment) we'll discuss here <-- since I already made the comment there >.<