Я получаю ошибку CROS при отправке запросов из моего ионного мобильного приложения в мой магазин woocommerce с использованием API woocommerce.
Я следовал этой настройке и следующим образом:
{
"name": "IonicApp",
"app_id": "09309832",
"type": "ionic-angular",
"integrations": {
"cordova": {}
},
"proxies": [
{
"path": "/api",
"proxyUrl": "https://mystore.net/index.php/wp-json/wc/v2"
}
]
}
Это запрос данных:
this.WooCommerce = WC({
url: "https://mystore.net/index.php",
consumerKey: CONSUMER_KEY,
consumerSecret: CONSUMER_SECRET,
wpAPI: true,
version: 'wc/v2'
});
this.WooCommerce.getAsync(`products/categories`).then((data) => {
console.log(JSON.parse(data));
}, (err) => {
console.log(err)
});
Это ошибка, которую я получаю:
Failed to load https://mystore.net/index.php/wp-json/wc/v2/products/categories: Redirect from 'https://mystore.net/index.php/wp-json/wc/v2/products/categories' to 'https://mystore.net/NeLVZ/index.php/wp-json/wc/v2/products?categories' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.