设置跨源标头后,API请求上的Magento 401

时间:2019-03-20 21:04:50

标签: magento magento2

我正在尝试通过React Native应用为Magento中的产品调用Web API。在其他堆栈交换问题和答案以及教程之后,我仍然收到401响应。我知道这个电话有效,因为我可以通过邮递员拨打电话。

更新:所以我没有解决它,但是我发现如果我使用axios,该请求将起作用。这似乎与提取有关。

.htaccess mod_headers.c设置

#"Added Prefix" = Table.TransformColumns(#"Changed Type", {{"JOB_NAME", each "x" & _, type text}}),
#"Added Suffix" = Table.TransformColumns(#"Added Prefix", {{"JOB_NAME", each _ & "x", type text}}),
#"Split Column by Character Transition" = Table.SplitColumn(#"Added Suffix", "JOB_NAME", Splitter.SplitTextByCharacterTransition((c) => not List.Contains({"0".."9"}, c), {"0".."9"}), {"JOB_NAME.1", "JOB_NAME.2"}),
#"Split Column by Character Transition1" = Table.SplitColumn(#"Split Column by Character Transition", "JOB_NAME.2", Splitter.SplitTextByCharacterTransition({"0".."9"}, (c) => not List.Contains({"0".."9"}, c)), {"JOB_NAME", "JOB_NAME.2"}),
#"Removed Columns" = Table.RemoveColumns(#"Split Column by Character Transition1",{"JOB_NAME.1", "JOB_NAME.2"})

app / etc / env.php

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"
Header set Access-Control-Allow-Methods "POST, GET, PUT, OPTIONS"

从React Native调用API

'x-frame-options' => 'CROSS-ORIGIN'

这还包括名为“客户”的网络集成,所有API选项均设置为可访问。

0 个答案:

没有答案