AngularJS $http.post() 到同一台机器的另一个端口

AngularJS $http.post() to another port at the same machine

我有一个 AngularJS 应用程序托管在本地主机的 nginx 服务器中,Rest 服务托管在 localhost:7001 的 Weblogic 中。

我正在尝试在 Angular 部分中执行此操作 post:

$http.post('localhost:7001/testApp/user/login', { username: username, password: password })
            .success(function (response) {
                callback(response);
});

这是我遇到的错误:

XMLHttpRequest cannot load localhost:7001/testApp/user/login. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

您应该在 URL:

中指定协议方案(httphttps、...)
$http.post('http://localhost:7001/testApp/user/login', { username: username, password: password })
        .success(function (response) {
            callback(response);
});