leventures / magento2-cors
A Magento 2 module that enables CORS on the GraphQL and REST Apis
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 8
Type:magento2-module
Requires
- php: >=7.0.0
Requires (Dev)
- phpunit/phpunit: ^8.2
- squizlabs/php_codesniffer: ^3.4
- dev-master
- 1.0.1
- 1.0.0
- dev-dependabot/npm_and_yarn/path-parse-1.0.7
- dev-dependabot/npm_and_yarn/hosted-git-info-2.8.9
- dev-dependabot/npm_and_yarn/lodash-4.17.21
- dev-dependabot/npm_and_yarn/handlebars-4.7.7
- dev-dependabot/npm_and_yarn/y18n-4.0.1
- dev-dependabot/npm_and_yarn/ini-1.3.8
- dev-dependabot/npm_and_yarn/yargs-parser-13.1.2
- dev-dependabot/npm_and_yarn/standard-version-8.0.1
This package is auto-updated.
Last update: 2024-09-12 00:44:37 UTC
README
Ever try to work with the Magento v2.3+ GraphQL API from your browser and see the following?
Access to XMLHttpRequest at 'https://my.magento.app' from origin 'http://my.local.env' 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 add the necessary CORS headers to Magento 2 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 API, allowing you to access the GraphQL API 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 leventures/magento2-cors
- Configure the package
- Enable the package
./bin/magento module:enable Graycore_Cors
Features
- Configurable
- Respects the full CORS Protocol
Access-Control-Allow-Origin
Access-Control-Allow-Methods
Access-Control-Allow-Headers
Access-Control-Max-Age
- Security By Default