fakeheal / cors-anywhere
cors-anywhere is a php reverse proxy which adds CORS headers to the proxy request.
v0.0.4
2023-06-15 11:37 UTC
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.0
- symfony/http-foundation: ^6.0
Requires (Dev)
- pestphp/pest: 2.x-dev
- phpstan/phpstan: 1.11.x-dev
- rector/rector: ^0.17.1
README
cors-anywhere
is a php reverse proxy which adds CORS headers to the proxy request.
Use Case
It can be used to access resources from third party websites when it's not possible to enable CORS on target website i.e. when you don't own that website.
Note from author: I am currently using to access Rescue Time's & trak.tv APIs, so I can sync my own data to conjure.so.
Documentation
Install
composer require fakeheal/cors-anywhere
Initialize
<?php 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 }
How to use
Once setup, you must pass a url parameter, for example if your Cors URL is the following: http://127.0.0.1:2000
Then you'd do the below, the url being the proxied site you want to use.
http://127.0.0.1:2000/?url=https://google.com
Acknowledgements
Running Tests
To run tests, run the following command
./vendor/bin/pest
Used By
This project is used by the following entities: