{"id":13711936,"url":"https://github.com/middlewares/cors","last_synced_at":"2025-05-06T21:32:40.703Z","repository":{"id":62528374,"uuid":"70394396","full_name":"middlewares/cors","owner":"middlewares","description":"PSR-15 middleware to implement Cross-Origin Resource Sharing (CORS)","archived":false,"fork":false,"pushed_at":"2025-03-26T14:44:07.000Z","size":43,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-04T12:19:39.911Z","etag":null,"topics":["cors","http","middleware","psr-15"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/middlewares.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-09T09:59:04.000Z","updated_at":"2025-03-23T10:17:30.000Z","dependencies_parsed_at":"2022-11-02T15:31:11.129Z","dependency_job_id":null,"html_url":"https://github.com/middlewares/cors","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Fcors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Fcors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Fcors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Fcors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/middlewares","download_url":"https://codeload.github.com/middlewares/cors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252772209,"owners_count":21801875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cors","http","middleware","psr-15"],"created_at":"2024-08-02T23:01:13.093Z","updated_at":"2025-05-06T21:32:40.420Z","avatar_url":"https://github.com/middlewares.png","language":"PHP","readme":"# middlewares/cors\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE)\n![Testing][ico-ga]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nMiddleware to implement Cross-Origin Resource Sharing (CORS) using [neomerx/cors-psr7](https://github.com/neomerx/cors-psr7).\n\n## Requirements\n\n* PHP \u003e= 7.2\n* A [PSR-7 http library](https://github.com/middlewares/awesome-psr15-middlewares#psr-7-implementations)\n* A [PSR-15 middleware dispatcher](https://github.com/middlewares/awesome-psr15-middlewares#dispatcher)\n\n## Installation\n\nThis package is installable and autoloadable via Composer as [middlewares/cors](https://packagist.org/packages/middlewares/cors).\n\n```sh\ncomposer require middlewares/cors\n```\n\n## Example\n\n```php\nuse Neomerx\\Cors\\Strategies\\Settings;\nuse Neomerx\\Cors\\Analyzer;\n\n$settings = new Settings();\n$settings-\u003esetServerOrigin('http', 'example.com', 123);\n\n$analyzer = Analyzer::instance($settings);\n\n$dispatcher = new Dispatcher([\n    new Middlewares\\Cors($analyzer)\n]);\n\n$response = $dispatcher-\u003edispatch(new ServerRequest());\n```\n\n## Usage\n\nYou have to provide a `Neomerx\\Cors\\Contracts\\AnalyzerInterface` to the constructor. See [neomerx/cors-psr7](https://github.com/neomerx/cors-psr7) for more info. Optionally, you can provide a `Psr\\Http\\Message\\ResponseFactoryInterface` as the second argument to create the responses. If it's not defined, [Middleware\\Utils\\Factory](https://github.com/middlewares/utils#factory) will be used to detect it automatically.\n\n```php\n$analyzer = Analyzer::instance($settings);\n$responseFactory = new MyOwnResponseFactory();\n\n$cors = new Middlewares\\Cors($analyzer, $responseFactory);\n```\n\n---\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information about recent changes and [CONTRIBUTING](CONTRIBUTING.md) for contributing details.\n\nThe MIT License (MIT). Please see [LICENSE](LICENSE) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/middlewares/cors.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-ga]: https://github.com/middlewares/cors/workflows/testing/badge.svg\n[ico-downloads]: https://img.shields.io/packagist/dt/middlewares/cors.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/middlewares/cors\n[link-downloads]: https://packagist.org/packages/middlewares/cors\n","funding_links":[],"categories":["Packages"],"sub_categories":["Security"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiddlewares%2Fcors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiddlewares%2Fcors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiddlewares%2Fcors/lists"}