**请求.png/.html资源是可以的
但是请求.php就出现了问题**
之前我用Wampserver32跑php
当时的代理是
'/sign': {
target: 'http://localhost:8088',
changeOrigin: true,
ws: true,
pathRewrite: {
'^/sign': '/'
}
},
是没问题的 现在我直接通过终端运行
$php -S localhost:8088
test.php文件目录是在项目里面的api文件夹下
这个是终端提示
Proxy error: Could not proxy request //test.php from 192.168.1.12:1010 to http://locahost:8088.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ENOTFOUND).
代理设置
api.js
浏览器控制台
test.php
<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Method: POST,GET');
header('Access-Control-Allow-Headers:Content-Type, api_key, Authorization');
echo 'hello world';
?>
test.php运行($php -S localhost:8088)结果
问题解决了...
问题不是跨域..T T,
是php设置返回格式错误了
同时加了
在 vue.config.js