Quantcast
Channel: Questions in topic: "webrequest"
Viewing all articles
Browse latest Browse all 387

WebGL CORS error when trying to get text from a URL. Even when CORS is set?

$
0
0
I'm trying to load high scores for my game from this URL: https://dirtylime.com/games/highscores/display.php?game=space_runner

Since uploading the WebGL build to a seperate domain it's failing to get the URL. I'm getting this Cross-Origin Resource Sharing error in the browser console:

Access to XMLHttpRequest at 'https://dirtylime.com/games/highscores/display.php?game=space_runner' from origin 'https://uploads.ungrounded.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

But my webpage does have a Access-Control-Allow-Origin header set to * so I can't figure out what could be stopping it.

I can confirm that the header is set using an online testing tool. http://tools.seobook.com/server-header-checker/?url=https%3A%2F%2Fdirtylime.com%2Fgames%2Fhighscores%2Fdisplay.php%3Fgame%3Dspace_runner&useragent=8&protocol=11

Here's the C# code I'm using to try load the URL:

UnityWebRequest hs_get = UnityWebRequest.Get(highscoreURL); yield return hs_get.SendWebRequest(); if (hs_get.isHttpError) { scoresText.text = "There was an error getting the highscores:\nPlease try again."; } else { scoresText.text = hs_get.downloadHandler.text; }

Viewing all articles
Browse latest Browse all 387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>