magento-api
magento-api copied to clipboard
CORS issue in Cordova app API Integration
Access to XMLHttpRequest at 'https://www.domain.com/staging/api/customer/[email protected]&password=xxx' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
#Solved by using Header always set Access-Control-Allow-Origin "*" Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" Header always set Access-Control-Max-Age "1000" Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
RewriteEngine On RewriteCond %{REQUEST_METHOD} OPTIONS RewriteRule ^(.*)$ $1 [R=200,L] in Root .htaccess