PHPackages                             graycore/magento2-cors - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. graycore/magento2-cors

ActiveMagento2-module[API Development](/categories/api)

graycore/magento2-cors
======================

A Magento 2 module that enables CORS on the GraphQL and REST Apis

v2.1.2(2mo ago)99516.1k↑29.8%33MITPHPCI passing

Since Jul 23Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/graycoreio/magento2-cors)[ Packagist](https://packagist.org/packages/graycore/magento2-cors)[ GitHub Sponsors](https://github.com/graycoreio)[ RSS](/packages/graycore-magento2-cors/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (9)Versions (21)Used By (0)

Magento 2 CORS
==============

[](#magento-2-cors)

[![Packagist Downloads](https://camo.githubusercontent.com/358900585913e685520acd089958bdb01cfad3513570e27b58b558d7dc4317fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f67726179636f72652f6d6167656e746f322d636f72733f636f6c6f723d626c7565)](https://packagist.org/packages/graycore/magento2-cors/stats)[![Packagist Version](https://camo.githubusercontent.com/daa682debcfe6478b25634dbc3e15168f042adeb468fe0a54016f523299d4297/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67726179636f72652f6d6167656e746f322d636f72733f636f6c6f723d626c7565)](https://packagist.org/packages/graycore/magento2-cors)[![Packagist License](https://camo.githubusercontent.com/770c3b732eccfebd7edf0cd675248e59a1e673a19ebdb806b70aa693f61b331c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f67726179636f72652f6d6167656e746f322d636f7273)](https://github.com/graycoreio/magento2-cors/blob/master/LICENSE)[![MageCheck Status](https://camo.githubusercontent.com/615b094b22938df9d3f89e93fe3765ef322d7483ea9e5e6fadf794d221393e57/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f67726179636f7265696f2f6d6167656e746f322d636f72732f636865636b2d657874656e73696f6e2e79616d6c3f266c6162656c3d4d616765436865636b266c6162656c436f6c6f723d316131613161)](https://github.com/graycoreio/magento2-cors/actions/workflows/check-extension.yaml)[![MageCheck Supported Version](https://camo.githubusercontent.com/7e39a6d24d42596e6ddf7d6a99b93d5ef0bfd0fd1190cdf79d08eb7d9e1ba773/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f63757272656e746c795f737570706f727465642d616e793f6c6162656c3d4d616765436865636b253230537570706f72746564266c6162656c436f6c6f723d31613161316126636f6c6f723d303930633962)](https://camo.githubusercontent.com/7e39a6d24d42596e6ddf7d6a99b93d5ef0bfd0fd1190cdf79d08eb7d9e1ba773/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f63757272656e746c795f737570706f727465642d616e793f6c6162656c3d4d616765436865636b253230537570706f72746564266c6162656c436f6c6f723d31613161316126636f6c6f723d303930633962)

Magento Version Support
-----------------------

[](#magento-version-support)

[![Magento v2.3 Supported](https://camo.githubusercontent.com/87cbb26d829fc5eba104e9ab7b0e41086947b7469962c909de8b3f953172ac67/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d6167656e746f2d322e332d627269676874677265656e2e7376673f6c6162656c436f6c6f723d326632623266266c6f676f3d6d6167656e746f266c6f676f436f6c6f723d66323637323426636f6c6f723d343634323436266c6f6e6743616368653d74727565267374796c653d666c6174)](https://camo.githubusercontent.com/87cbb26d829fc5eba104e9ab7b0e41086947b7469962c909de8b3f953172ac67/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d6167656e746f2d322e332d627269676874677265656e2e7376673f6c6162656c436f6c6f723d326632623266266c6f676f3d6d6167656e746f266c6f676f436f6c6f723d66323637323426636f6c6f723d343634323436266c6f6e6743616368653d74727565267374796c653d666c6174)[![Magento v2.4 Supported](https://camo.githubusercontent.com/7306d94da407bf4898f770b04a6a7c97fe2ca81141cf9a821b109b3d731f915a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d6167656e746f2d322e342d627269676874677265656e2e7376673f6c6162656c436f6c6f723d326632623266266c6f676f3d6d6167656e746f266c6f676f436f6c6f723d66323637323426636f6c6f723d343634323436266c6f6e6743616368653d74727565267374796c653d666c6174)](https://camo.githubusercontent.com/7306d94da407bf4898f770b04a6a7c97fe2ca81141cf9a821b109b3d731f915a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d6167656e746f2d322e342d627269676874677265656e2e7376673f6c6162656c436f6c6f723d326632623266266c6f676f3d6d6167656e746f266c6f676f436f6c6f723d66323637323426636f6c6f723d343634323436266c6f6e6743616368653d74727565267374796c653d666c6174)

Ever try to work with the Magento GraphQL API or REST API from your browser and see the following?

```
Access to XMLHttpRequest at 'https://my.magento.app' from origin 'http://my.webapp.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
```

This package allows you to securely add the necessary CORS headers to the Magento 2 GraphQL or REST APIs with ease.

Purpose
-------

[](#purpose)

When building a headless application for Magento, or working with a client that respects the CORS protocol, you will need [CORS headers](https://fetch.spec.whatwg.org/#http-cors-protocol) on your backend resource.

This package will add configurable CORS Resource headers to the Magento 2 GraphQL or REST APIs, allowing you to access the GraphQL or REST APIs from your browser.

Getting Started
---------------

[](#getting-started)

This module is intended to be installed with [composer](https://getcomposer.org/). From the root of your Magento 2 project:

1. Download the package

```
composer require graycore/magento2-cors
```

2. [Configure the package](/docs/stories/configuring-the-headers.md)
3. Enable the package

```
./bin/magento module:enable Graycore_Cors
```

Features
--------

[](#features)

- [Configurable](./docs/stories/configuring-the-headers.md)
- [Respects the full CORS Protocol](https://fetch.spec.whatwg.org/#http-cors-protocol)

    - `Access-Control-Allow-Origin`
    - `Access-Control-Allow-Methods`
    - `Access-Control-Allow-Headers`
    - `Access-Control-Max-Age`
    - `Access-Control-Expose-Headers`
    - `Access-Control-Allow-Credentials`
- [Security By Default](./docs/stories/security.md#security-by-default)
- [Vary: Origin](https://fetch.spec.whatwg.org/#cors-protocol-and-http-caches)

Helpful Links
-------------

[](#helpful-links)

- [FAQ](./docs/faq/faqs.md)
    - [Can I configure this from the admin panel?](./docs/faq/faqs.md#can-i-configure-this-from-the-admin-panel)

Upgrading
---------

[](#upgrading)

- [Semver Policy](https://semver.org/)
- [Guide](./docs/upgrading/guide.md)

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance84

Actively maintained with recent releases

Popularity54

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 80.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~172 days

Recently: every ~308 days

Total

15

Last Release

80d ago

Major Versions

v1.6.0 → v2.0.0-rc.02022-06-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/cede4d8ff3624bd4e509cebd8a3da9abada797eb8e0737c6db26097fce82e67e?d=identicon)[damienwebdev](/maintainers/damienwebdev)

---

Top Contributors

[![damienwebdev](https://avatars.githubusercontent.com/u/9029654?v=4)](https://github.com/damienwebdev "damienwebdev (100 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![Nolan-Arnold](https://avatars.githubusercontent.com/u/44958241?v=4)](https://github.com/Nolan-Arnold "Nolan-Arnold (7 commits)")[![gray-bot](https://avatars.githubusercontent.com/u/120588553?v=4)](https://github.com/gray-bot "gray-bot (4 commits)")[![jburnumHVT](https://avatars.githubusercontent.com/u/92030481?v=4)](https://github.com/jburnumHVT "jburnumHVT (1 commits)")[![kniziol](https://avatars.githubusercontent.com/u/947620?v=4)](https://github.com/kniziol "kniziol (1 commits)")[![griest024](https://avatars.githubusercontent.com/u/5853222?v=4)](https://github.com/griest024 "griest024 (1 commits)")[![LoogleCZ](https://avatars.githubusercontent.com/u/13019504?v=4)](https://github.com/LoogleCZ "LoogleCZ (1 commits)")[![mage2pratik](https://avatars.githubusercontent.com/u/33807558?v=4)](https://github.com/mage2pratik "mage2pratik (1 commits)")[![kristof-ringleff](https://avatars.githubusercontent.com/u/47804013?v=4)](https://github.com/kristof-ringleff "kristof-ringleff (1 commits)")

---

Tags

corscors-headerscors-protocolgraphqlhacktoberfestmagentomagento2magento2-extensionmagento2-modulephprest

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/graycore-magento2-cors/health.svg)

```
[![Health](https://phpackages.com/badges/graycore-magento2-cors/health.svg)](https://phpackages.com/packages/graycore-magento2-cors)
```

###  Alternatives

[smile/elasticsuite

Magento 2 merchandising and search engine built on ElasticSearch

8044.5M33](/packages/smile-elasticsuite)[mollie/magento2

Mollie Payment Module for Magento 2

1121.6M10](/packages/mollie-magento2)[elgentos/module-prismicio

Magento 2 - Prismic.io integration

39112.0k3](/packages/elgentos-module-prismicio)[zepgram/module-rest

Technical module to industrialize API REST call with dependency injection pattern using Guzzle library

1326.2k](/packages/zepgram-module-rest)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
