Jump to content

"No 'Access-Control-Allow-Origin' header is present" Only happens when trying to loud audio files


Normangorman
 Share

Recommended Posts

I'm loading the static assets for my game from a cdn.

Previously I faced problems with the 'No 'Access-Control-Allow-Origin' header is present' error, which I overcame by setting game.load.crossOrigin = "Anonymous".

However now I am trying to load some .ogg files from a directory on the server, and the error is back. A sample from the Javascript console is:

 

XMLHttpRequest cannot load http://mycdn.com/static/games/mygame/sounds/power_up.ogg. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. 

 

Localhost:8080 is the port on which I am running a grunt server. 

 

I'm loading static files using the standard Phaser.Loader method:

 

game.load.image('cloud1', 'mycdn.com/images/cloud1.png');

 

Does anyone have any ideas as to why this issue might be happening?

Note that the problem only occurs for audio files.

Anything I load with with game.load.image(..) or game.load.spritesheet(..) is fine.

It's game.load.audio(..) that doesn't work.

Link to comment
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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...