Newbie struggling with CORS issues.

Recommended Posts

Hi guys,


I'm looking for a solid HTML5 platform to develop my game on and I thought I'd start by reviewing Phaser - It looks like it has everything I need!


However, moving to HTML5 development, I realise I have to run the game on a local server, which I've never done before. Immediately trying to follow the first Phaser tutorial here I run into a CORS issue trying to load the star. 


I've followed the setup instructions as listed on the Phaser site, I've browsed the forums and done multiple google searches and... to be honest... I don't really understand any of what I'm being instructed to do.


The error in the log appears as:


Uncaught SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at file:///Applications/MAMP/htdocs/phasertest/phaser_tutorial_02/assets/star.png may not be loaded.


What do I do? A little step-by step would help a lot. I'm developing on OSX and running  a local server through MAMP, if that's any help.


Thanks so much!


- Greg

Share this post

Link to post
Share on other sites

Hey Mike,


Thanks for your response! That's the actual path of the image, not what's in script. I'd rather not hardcode asset paths. This is what my script looks like. Sorry, I should have posted this before.

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });function preload() {	game.load.image('sky', 'assets/sky.png');    game.load.image('ground', 'assets/platform.png');    game.load.image('star', 'assets/star.png');    game.load.spritesheet('dude', 'assets/dude.png', 32, 48);}function create() {	game.add.sprite(0, 0, 'star');}function update() {}

Share this post

Link to post
Share on other sites

Do you open the html form the webserver ?


Sounds like you open the html like: file:///D:/xampp/htdocs/Phaser/AdventureJS/index.html


Try to open: http://localhost:8888/


also check if the server is running (Apache is started).


And your game should be here: http://localhost:8888/phasertest

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.