Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/graycoreio/magento2-cors
A Magento 2 module that enables configurable CORS Headers on the GraphQL and REST APIs
https://github.com/graycoreio/magento2-cors
cors cors-headers cors-protocol graphql hacktoberfest magento magento2 magento2-extension magento2-module php rest
Last synced: 28 days ago
JSON representation
A Magento 2 module that enables configurable CORS Headers on the GraphQL and REST APIs
- Host: GitHub
- URL: https://github.com/graycoreio/magento2-cors
- Owner: graycoreio
- License: mit
- Created: 2019-07-08T13:11:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-10T14:50:46.000Z (2 months ago)
- Last Synced: 2024-10-10T15:38:58.644Z (2 months ago)
- Topics: cors, cors-headers, cors-protocol, graphql, hacktoberfest, magento, magento2, magento2-extension, magento2-module, php, rest
- Language: PHP
- Homepage: https://packagist.org/packages/graycore/magento2-cors
- Size: 470 KB
- Stars: 85
- Watchers: 5
- Forks: 30
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-magento2 - graycoreio/magento2-cors - Enables configurable CORS Headers on the (Open Source Extensions / Development Utilities)
- awesome-magento2 - graycoreio/magento2-cors - Enables configurable CORS Headers on the (Open Source Extensions / Development Utilities)
README
# Magento 2 CORS
[![Packagist Downloads](https://img.shields.io/packagist/dm/graycore/magento2-cors?color=blue)](https://packagist.org/packages/graycore/magento2-cors/stats)
[![Packagist Version](https://img.shields.io/packagist/v/graycore/magento2-cors?color=blue)](https://packagist.org/packages/graycore/magento2-cors)
[![Packagist License](https://img.shields.io/packagist/l/graycore/magento2-cors)](https://github.com/graycoreio/magento2-cors/blob/master/LICENSE)
[![Unit Test](https://github.com/graycoreio/magento2-cors/actions/workflows/unit.yaml/badge.svg)](https://github.com/graycoreio/magento2-cors/actions/workflows/unit.yaml)
[![Integration Test](https://github.com/graycoreio/magento2-cors/actions/workflows/integration.yaml/badge.svg)](https://github.com/graycoreio/magento2-cors/actions/workflows/integration.yaml)
[![Installation Test](https://github.com/graycoreio/magento2-cors/actions/workflows/install.yaml/badge.svg)](https://github.com/graycoreio/magento2-cors/actions/workflows/install.yaml)## Magento Version Support
![Magento v2.3 Supported](https://img.shields.io/badge/Magento-2.3-brightgreen.svg?labelColor=2f2b2f&logo=magento&logoColor=f26724&color=464246&longCache=true&style=flat)
![Magento v2.4 Supported](https://img.shields.io/badge/Magento-2.4-brightgreen.svg?labelColor=2f2b2f&logo=magento&logoColor=f26724&color=464246&longCache=true&style=flat)Ever try to work with the Magento GraphQL API or REST API from your browser and see the following?
```txt
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
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
This module is intended to be installed with [composer](https://getcomposer.org/). From the root of your Magento 2 project:1. Download the package
```bash
composer require graycore/magento2-cors
```
2. [Configure the package](/docs/stories/configuring-the-headers.md)
3. Enable the package```bash
./bin/magento module:enable Graycore_Cors
```## 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
* [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
* [Semver Policy](https://semver.org/)
* [Guide](./docs/upgrading/guide.md)