Laravel 5 CORS 问题与 Ionic Angular

Laravel 5 CORS-issue vs. Ionic Angular

我目前正在用 Laravel 5 制作一个 Ionic/Cordova-application 作为 Rest-server(我第一次编写 PHP-server)。 使用 Postman,我所有 Get/Post/Update/Delete-functions 都在 Laravel 和客户端 (Ionic Cordova) 上工作。我能够将数据发送到 http://postcatcher.in using Chrome Allow-Control-Allow-Origin plugin.。没有插件,我得到这个错误:

由于这个问题显然只发生在开发模式下(在浏览器中测试客户端时),我认为使用插件开发是可以的。

当我尝试通过 Ionic Cordova 将数据发送到 Laravel 时,出现此错误(即使使用 Allow-Control-Allow-Origin 插件:

我试过很多东西,比如https://github.com/barryvdh/laravel-cors, which just doesn't seem to work for me. Neither does suggestions in this forum, using CORS-middlewares. https://laracasts.com/discuss/channels/requests/laravel-5-cors-headers-with-filters

我认为这是一个 Laravel 问题,但我不是 100% 确定。

为了发布服务器,我使用 php artisan serve,给它 localhost:8000。 对于应用程序,我写了:ionic serve,它给出了 localhost:8100.

最后,这是我用来在 Ionic 端发送数据的代码:

.factory('userFactory', function($http, $q) {
 return{
    createuser : function(info) {

        var deferred = $q.defer();
        $http.post('localhost:8000/users', info) 
        .success(function(response, status){
            deferred.resolve(response);
        })
        .error(function() {
            console.log('SOMETHING WENT WRONG');
        });
                return deferred.promise;
  }

 }
})

任何 帮助真的很感激。真的被这个问题困住了。

原来我是个彻头彻尾的白痴。我只需要在URL前面写上"http://"。新手错误。 编辑:如果有人对我有建议,我会将问题开放半小时。