PHP code example of fakeheal / cors-anywhere

1. Go to this page and download the library: Download fakeheal/cors-anywhere library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fakeheal / cors-anywhere example snippets




use Fakeheal\CorsAnywhere\Exceptions\CorsAnywhereException;
use Fakeheal\CorsAnywhere\Proxy;

// ...

try {
    $server = new Proxy([
        // allowed hosts to proxy to
        'rescuetime.com',
        'google.com'
    ], [
        // allowed headers
        'Content-Type',
        'Accepts'    
    ]);

    // call handle that... handles everything
    $server->handle();
} catch (CorsAnywhereException $e) {
    die($e->getMessage()); // or die trying
}