定制 fakeheal/cors-anywhere 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fakeheal/cors-anywhere

最新稳定版本:v0.0.4

Composer 安装命令:

composer require fakeheal/cors-anywhere

包简介

cors-anywhere is a php reverse proxy which adds CORS headers to the proxy request.

README 文档

README

Tests Latest Stable Version Total Downloads License PHP Version Require

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:

License

MIT

统计信息

  • 总下载量: 35
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-14