New: Unity WebGL CORS Fix Guide

Ship Browser Games
Without CORS Errors

Connect to external APIs, load assets from CDNs, and deploy on Itch.io—all without cross-origin headaches. Works with Unity, Godot, Phaser, and any browser-based game.

// Just prefix your URL:
https://corsproxy.io/?url=https://api.gameserver.com/data

Leaderboards & Scores

Connect to external leaderboard APIs and score tracking services directly from your browser game.

fetch(CORS_PROXY + leaderboardAPI)

Player Authentication

Integrate with PlayFab, Firebase, or custom auth backends for player accounts and saves.

fetch(CORS_PROXY + authEndpoint)

External Assets

Load sprites, audio, and textures from external CDNs without tainted canvas errors.

this.load.image(CORS_PROXY + cdnUrl)

Game Analytics

Send player events and telemetry to analytics platforms from WebGL builds.

fetch(CORS_PROXY + analyticsAPI)

Multiplayer Config

Fetch server lists and matchmaking data before establishing WebSocket connections.

fetch(CORS_PROXY + serverListAPI)

DLC & Hot Updates

Download additional content and game updates from your servers at runtime.

fetch(CORS_PROXY + dlcContentURL)

Works with Your Game Engine

Copy-paste examples for Unity, Godot, Phaser, and vanilla JavaScript.

// Unity WebGL - Load external API data
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class GameAPI : MonoBehaviour
{
    private const string CORS_PROXY = "https://corsproxy.io/?url=";

    public IEnumerator FetchLeaderboard()
    {
        string apiUrl = "https://api.mygame.com/leaderboard";

        #if UNITY_WEBGL && !UNITY_EDITOR
            apiUrl = CORS_PROXY + UnityWebRequest.EscapeURL(apiUrl);
        #endif

        using (var request = UnityWebRequest.Get(apiUrl))
        {
            yield return request.SendWebRequest();
            if (request.result == UnityWebRequest.Result.Success)
                ProcessLeaderboard(request.downloadHandler.text);
        }
    }
}
Response
Select a tab to run the request.
// Phaser.js - Load external assets without CORS errors
const CORS_PROXY = 'https://corsproxy.io/?url=';

function preload() {
    this.load.setCORS('anonymous');

    // Load sprites from external CDN
    const spriteUrl = 'https://cdn.example.com/sprites/player.png';
    this.load.image('player', CORS_PROXY + encodeURIComponent(spriteUrl));

    // Load game data from API
    const dataUrl = 'https://api.mygame.com/levels';
    this.load.json('levels', CORS_PROXY + encodeURIComponent(dataUrl));
}

function create() {
    const player = this.add.sprite(400, 300, 'player');
    const levels = this.cache.json.get('levels');
    console.log('Loaded levels:', levels);
}
Response
Select a tab to run the request.
# Godot 4 - HTTP requests in web exports
extends Node

const CORS_PROXY = "https://corsproxy.io/?url="

func _ready():
    fetch_player_data()

func fetch_player_data():
    var url = "https://api.mygame.com/player/stats"

    # Use proxy for web builds
    if OS.has_feature("web"):
        url = CORS_PROXY + url.uri_encode()

    var http_request = HTTPRequest.new()
    add_child(http_request)
    http_request.request_completed.connect(_on_request_completed)
    http_request.request(url)

func _on_request_completed(result, code, headers, body):
    if result == HTTPRequest.RESULT_SUCCESS:
        var json = JSON.parse_string(body.get_string_from_utf8())
        print("Player stats: ", json)
Response
Select a tab to run the request.
// Browser game - Fetch game config before WebSocket connection
const CORS_PROXY = 'https://corsproxy.io/?url=';

async function initMultiplayer() {
    // Fetch server list via CORS proxy
    const configUrl = 'https://api.gameserver.com/servers';
    const response = await fetch(CORS_PROXY + encodeURIComponent(configUrl));
    const servers = await response.json();

    // Connect to best server (WebSocket doesn't need CORS proxy)
    const bestServer = servers.sort((a, b) => a.latency - b.latency)[0];
    const socket = new WebSocket(bestServer.wsUrl);

    socket.onopen = () => console.log('Connected to game server!');
    socket.onmessage = (e) => handleGameEvent(JSON.parse(e.data));
}
Response
Select a tab to run the request.
Understanding the Problem

Why CORS Affects Your Game

When you build a game for WebGL or HTML5, your code compiles to WebAssembly that runs inside the browser. Even though you write C# (Unity) or GDScript (Godot), network requests use the browser's fetch API—and browsers enforce CORS on all cross-origin requests.

This means your game works perfectly in the editor, but fails with CORS errors when deployed to the web.

Access to fetch at 'https://api.gameserver.com' from origin 'https://itch.io' has been blocked by CORS policy

Works in Editor

Unity Editor and Godot make direct HTTP calls without browser restrictions.

Fails in Browser

WebGL builds use browser APIs. The browser blocks cross-origin requests without proper CORS headers.

Fixed with CORSPROXY

Route requests through our proxy to add the required CORS headers automatically.

Ship your game

Ready to fix your CORS errors?

Start using CORSPROXY for free. No signup required for basic usage.