CORS, Absolute URL and CDN

0 favourites
  • 2 posts
  • I created some games in Construct, and they share the content.

    What I want to do is to put the absolute URL to the images and the media in the exporter, and all of the images instances to have this parameter set image.crossOrigin = "anonymous";

    this way I could cache the content much easier and publish much faster, now I have to publish and open the files to change all of the links

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I created some Regular expressions to change the exported script, if anyone have the same problem

    search "^(.*)var (.*) = new Image\\(\\)\\;",

    replace "$1var $2 = new Image()/**/;\r\n$1$2.crossOrigin = 'anonymous';"

    search "^(.*) = new Image\\(\\)\\;",

    replace "$1 = new Image()/**/;\r\n$1.crossOrigin = 'anonymous';"

    search "\"images/",

    replace "\"http://your url here/images/"

    search "\"media/",

    replace "\"http://your url here/media/"

    you can change the http:// to // if you want to work in both http and https, but I haven't tested yet

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)