Giter Site home page Giter Site logo

medz / cors Goto Github PK

View Code? Open in Web Editor NEW
274.0 10.0 23.0 98 KB

🔮Supported(Laravel/Lumen/PSR-15/Swoft/Slim/ThinkPHP) - PHP CORS (Cross-origin resource sharing) middleware.

License: MIT License

PHP 100.00%
cors php cors-request request response laravel psr-7 cors-middleware middleware laravel5

cors's Introduction

Hi there 👋

Keep calm and coding.

I'm Seven Du, a full-stack developer starting a business. Founded Odroe Inc, a company dedicated to open source software.

Motto: if(true == false) false = true

🇨🇳 Chengdu・👨🏻‍💻 Full-stack Developer

E-Mail: shiweidu at outlook dot com

Language:Dart❤️、Rust🤩、TypeScript/JavaScript(ES6+)🥳、Swift

Framework:Flutter、Vue.js、React.js、Nest.js、And any more...

cors's People

Contributors

fossabot avatar medz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cors's Issues

slim Invalid setting

In my slim project,Still reporting an error:No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access.
My setting:
$set = [
'allow-credentials' => false, // set "Access-Control-Allow-Credentials" 👉 string "false" or "true".
'allow-headers' => [''], // ex: Content-Type, Accept, X-Requested-With
'expose-headers' => [],
'origins' => ['
'], // ex: http://localhost
'methods' => ['*'], // ex: GET, POST, PUT, PATCH, DELETE
'max-age' => 0,
];
$app->add(new Medz\Cors\Slim\Cors($set));

Access-Control-Max-Age 没设置上哈

不知道为什么 我设置了 Access-Control-Max-Age
'max-age' => env('CORS_ACCESS_CONTROL_MAX_AGE', 3600),
但是在返回的包头里 却没有这个值
我用的是 laravel 5.5
浏览器是 360急速版

小白的问题

首先感谢大神写的这个中间件!

说一下我的疑惑。我对PHP了解不多,只是刚开始用thinkPHP写写接口。现在遇到了跨域的麻烦,找了很多方法感觉还是不够好,所以想试试这个CORS中间件。

已经用composer在thinkPHP5工程下安装了medz/cors。
接下来我该怎么做?这段代码应该写在框架的哪个位置?完全不知道怎么下手啊,没有用过中间件,还请各位简单说明一下,谢谢!!

`use Medz\Cors\Cors;

$cors = new Cors($config); // The $config 👉 config/cors.php file.
$cors->setRequest($requestType, $request); // The $request is empty array or is NULL or $_REQUEST
$cors->setResponse($responseType, $response); // The $response is empty array.
$cors->handle();

$response = $cors->getResponse();`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.