我使用vue.js http post在我的index.php中调用一个方法。我发送请求时显示错误
阻止跨源请求:同源策略禁止在http://localhost/project1/public/index.php/signup读取远程资源。 (原因:CORS预检频道没有成功)。
我的vue.js请求是
this.$http.post('http://localhost/project1/public/index.php/signup', this.dataObject,
function(response) {
console.log(response)
});
在index.php的开头,我添加了
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token , Authorization');
signup();
function signup(){
echo "here";
}