【发布时间】:2018-07-31 23:13:06
【问题描述】:
就是这样。我在服务器上运行我的 API,它在服务器的 localhost:8080 中运行。 有人告诉我,为了从我的机器(使用 vpn)从本地访问 api,url 是 xxx.xxx.xxx:8080 所以我尝试了
$http({
url:'http://xxx.xxx.xxx.xxx:8080/login',
method:"POST",
data:{user:$scope.user, password:$scope.password}
})
而我的api路由是这样的
$app->post('/login', function ($request, $response) {
//Parametros que se pasan a la api
$input = $request->getParsedBody();
$req = $input['usuario'];
$md5pass = md5($input['password']);
$sth = $this->db->prepare("query");
//bindParam pasandole los parametros para evitar injecciones sql
$sth->bindParam("password", md5($input['password']));
$sth->bindParam("usuario", $input['usuario']);
$sth->execute();
$todos = $sth->fetchAll();
$cliente_id = $todos->cliente_id;
....
但我从 chrome 收到此错误
OPTIONS http://xxx.xxx.xxx.xxx:8080/login net::ERR_CONNECTION_REFUSED
知道会是什么吗?我是否需要将设置更改为我的 Slim 配置或其他内容?
【问题讨论】: