如何配置apache VHost以与axios.post一起使用?

问题描述 投票:0回答:1

我正在带有虚拟主机的Windows 10上运行WAMP。从本地主机:<< [这些站点在浏览器中以及与axios.get一起正常运行到以下URL。使用post时(如下所示),请求不会得到响应。

axios.post('http://test.local/load/notifications/', { someData: 'someVal'}, { headers: { "Access-Control-Allow-Origin": "*" }).then((resp) => { console.log(resp); // no response }, (error) => { // The request was made but no response was received })
  
我已经尝试过此请求

with和without配置对象。

在我的httpd.conf文件中,使用以下目录节点启用了虚拟主机。

<Directory /> AllowOverride none Require local Require ip 192.168.1.5 </Directory>

虚拟主机配置如下:

<VirtualHost *:80> DocumentRoot "F:\test\public" ServerName test.local ServerAlias test.local CustomLog "logs/test.local-access.log" common ErrorLog "logs/test.local-error.log" </VirtualHost>

我在php页面上的CORS标头设置为header("Access-Control-Allow-Origin: *");,所以我知道它与CORS无关。没有错误消息,端点只是不返回响应。

这是请求问题还是apache配置问题?

apache axios cors wamp vhosts
1个回答
0
投票
您是否故意使用<Directory />?我不确定这是否是您的帖子中的错字,还是由于Directory节点的开始标记中的/而导致配置不正确。

我从未在有效的conf中看到它(尽管也许是有效的?),但是它几乎引起了我的注意,好像它是一个自动关闭的HTML标记。

© www.soinside.com 2019 - 2024. All rights reserved.