Ionic App (using ngResource) with RESTful Laravel API getting net::ERR_UNKNOWN_URL_SCHEME

1.3k views Asked by At

I've used this solution to disable web security in Chrome so I can have localhost:8100 served by Ionic and localhost:8000 served by Laravel communicate without XSS issues, but now I'm getting this error in my Chrome console:

POST localhost:8000/api/user net::ERR_UNKNOWN_URL_SCHEME

I found a couple different solutions for this, but they all seem to be related to third-party services being used on mobile devices (ex. OAuth), old Chromium bugs, or a few Chrome apps, but I'm just trying to round trip with my RESTful endpoints using Ionic/AngularJS ngResource and Laravel's RESTful routing in my development environment.

I'm using an interceptor to switch between asset and API requests:

.factory('API', ['ConfigSettings',
    function (ConfigSettings) {

        var service = {
            request: function (config) {

                if (config.url.indexOf("/api") > -1) {
                    config.url = ConfigSettings.host + ':' + ConfigSettings.port + config.url;
                }

                return config;
            }
        }

        return service;
    }])

.config(['$httpProvider', function ($httpProvider) {

    $httpProvider.interceptors.push('API');
}]);

Anyone know what this error means in my case and how to fix it?

0

There are 0 answers