graycore / magento2-cors
A Magento 2 module that enables CORS on the GraphQL and REST Apis
Fund package maintenance!
graycoreio
Installs: 320 637
Dependents: 1
Suggesters: 0
Security: 0
Stars: 86
Watchers: 5
Forks: 31
Open Issues: 0
Type:magento2-module
Requires
- magento/framework: ^102.0 || ^103.0
Requires (Dev)
- magento/magento-coding-standard: >=6.0
- phpunit/phpunit: ^8.2 || ^9.0
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-12-10 15:11:26 UTC
README
Magento Version Support
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
When building a headless application for Magento, or working with a client that respects the CORS protocol, you will need CORS headers 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. From the root of your Magento 2 project:
- Download the package
composer require graycore/magento2-cors
- Configure the package
- Enable the package
./bin/magento module:enable Graycore_Cors
Features
-
Respects the full 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