title: Slim POST calls do not work from Ionic app
body: <p>I have an app to make calls from the POST and GET a REST API , APP 's 'm developing with Ionic and when emulate the app using the command: </p>
  
  <pre><code>ionic serve --lab
  </code></pre>
  
  <p>this works perfectly, but when I go to the app device calls to the API report me 404 , I leave details of my APP:</p>
  
  <p><strong>app.constants.js:</strong></p>
  
  <pre><code>.constant('REST_SERVICE', {
      url: 'http://skulapp.com/nuevo/service',
      services: {
          profile:              '/get_profile/profile'/*,
          contacto:           '/contactos/',
          contactosExport:     '/contactosExport/',
          campanna:           '/campannas/',
          sync_contactos:     '/sync_contactos/',
          sync_campannas:     '/sync_campannas/'*/
      }
  })
  </code></pre>
  
  <p><strong>app.controller.js:</strong> This function makes use of the service: _Auth_Service</p>
  
  <pre><code>$scope.login = function(_credentials){
          if(_credentials != null){
              $ionicLoading.show({
                  template: '&lt;ion-spinner icon="lines" class="spinner-calm"&gt;&lt;/ion-spinner&gt;'
              });
              _Auth_Service.verify({user: _credentials.user, pass: hex_md5(_credentials.pass)}).then(function(profile){
                  $state.go('main.dashboard', {}, {reload: true});
                  //console.log(profile);
                  $scope.setCurrentUsername(profile);
                  $ionicLoading.hide();
              }, function(err) {
                  var alertPopup = $ionicPopup.alert({
                      title: 'Usuario no Valido',
                      template: 'Por favor revise su usuario y contraseña'
                  });
                  $ionicLoading.hide();
              });
          } else
              var alertPopup = $ionicPopup.alert({
                  title: 'Inicio Cancelado',
                  template: 'Ingrese su usuario y contraseña'
              });
      }
  </code></pre>
  
  <p><strong>app.services.js:</strong> Service _Auth_Service, use service _API </p>
  
  <pre><code>    .service('_Auth_Service', function($q, $http, _API, USER_ROLES){
  
          var authService = {};
          var LOCAL_TOKEN_KEY = 'LocalAppToken';
          var username = '';
          var isAuthenticated = false;
          var role = '';
          var authToken;
  
          authService.verify = function(credentials){
              return _API.get('profile', credentials).then(function(res){
                  console.log(res);
                  //console.log(res.data['_id_PER']);
                  storeUserCredentials(credentials.user + '.yourServerToken');
                  storeUserRol(res.data[0].Rol_USU)
                  return res.data[0];
              });
          };
  
          return authService;
  
  function loadUserCredentials() {
          var token = window.localStorage.getItem(LOCAL_TOKEN_KEY);
          if (token) {
              useCredentials(token);
          }
      }
  
          function storeUserCredentials(token) {
              window.localStorage.setItem(LOCAL_TOKEN_KEY, token);
              useCredentials(token);
          }
  
          function useCredentials(token) {
              username = token.split('.')[0];
              isAuthenticated = true;
              authToken = token;
              console.log('usa credenciales: ' + token + ' isAuthenticated: ' + isAuthenticated);
              // Set the token as header for your requests!
              $http.defaults.headers.common['X-Auth-Token'] = token;
          }
  
          function storeUserRol(rol) {
              //console.log('Rol: '+rol);
              role = rol;
          }
  
          loadUserCredentials();
          return {
              login: login,
              logout: logout,
              isAuthorized: isAuthorized,
              isAuthenticated: function() {
                  return isAuthenticated;
              },
              username: function() {
                  return username;
              },
              role: function() {
                  return role;
              }
          };
      })
  
  .service('_API', function($http, REST_SERVICE){
  
      this.get = function(_service, _data){
          var _url = REST_SERVICE.url+REST_SERVICE.services[_service];
          angular.forEach(_data, function(val, key){
              _url += '/' + val;
          });
          for (var i = 0; i &lt; _data.length; i++){
              console.log(_data[i]);
              _url += '/' + _data[i];
          }
          return $http.get(_url);
      }
  
      this.post = function(_service, _data){
          var _url = REST_SERVICE.url+REST_SERVICE.services[_service];
          //console.log(_data);
          return $http.post(_url, _data);
      }
  
  })
  </code></pre>
  
  <p><strong>REST API:</strong> get_profile/profile</p>
  
  <pre><code>$app-&gt;group('/get_profile', function() use($app){
  
  
          $app-&gt;post('/profile', function() use($app){
              try{
                  //$app-&gt;response()-&gt;header("Content-Type", "application/json");
  
                  $_datos = $app-&gt;request();
                  //$objDatos = json_decode(file_get_contents("php://input"));
  
                  $body = $_datos-&gt;getBody();
                  $objDatos = json_decode($body);
  
                  $_jobs = new Jobs();
  
                  //$_sql = 'SELECT u._id_PER, p._id_IMA, p.Nombre_PER, p.Apellidos_PER, p.Identificacion_PER, p.Telefono_PER, p.Celular_PER, p.Correo_PER, p.Sexo_PER, p.Direccion_PER, t.Nombre_TPO Tipo_PER, u.Nombre_USU, u.Clave_USU, u.SO_Plataforma_USU, u.Rol_USU, p.Creado_PER Actualizado_PER FROM Usuarios u INNER JOIN Personas p ON p._id = u._id_PER INNER JOIN Tipos t ON t._id = p._id_TPP WHERE (Nombre_USU = "'.$objDatos-&gt;user.'") AND (Clave_USU = "'.$objDatos-&gt;pass.'")';
  
                  $_sql = 'SELECT u._id_PER, p._id_IMA, p.Nombre_PER, p.Apellidos_PER, p.Identificacion_PER, p.Telefono_PER, p.Celular_PER, p.Correo_PER, p.Sexo_PER, p.Direccion_PER, t.Nombre_TPO Tipo_PER, u.Nombre_USU, u.Clave_USU, u.SO_Plataforma_USU, u.Rol_USU, p.Creado_PER Actualizado_PER FROM Usuarios u INNER JOIN Personas p ON p._id = u._id_PER INNER JOIN Tipos t ON t._id = p._id_TPP WHERE (Nombre_USU = "'.$objDatos-&gt;{'user'}.'") AND (Clave_USU = "'.$objDatos-&gt;{'pass'}.'")';
  
                  //$_sql = 'SELECT u._id_PER, p._id_IMA, p.Nombre_PER, p.Apellidos_PER, p.Identificacion_PER, p.Telefono_PER, p.Celular_PER, p.Correo_PER, p.Sexo_PER, p.Direccion_PER, t.Nombre_TPO Tipo_PER, u.Nombre_USU, u.Clave_USU, u.SO_Plataforma_USU, u.Rol_USU, p.Creado_PER Actualizado_PER FROM Usuarios u INNER JOIN Personas p ON p._id = u._id_PER INNER JOIN Tipos t ON t._id = p._id_TPP WHERE (Nombre_USU = "'.$_datos-&gt;post('user').'") AND (Clave_USU = "'.$_datos-&gt;post('pass').'")';
  
                  $app-&gt;response-&gt;headers-&gt;set("Content-type", "application/json");
                  $app-&gt;response-&gt;setHeader('Access-Control-Allow-Origin', '*');
                  $app-&gt;response-&gt;status(200);
                  $app-&gt;response-&gt;body(json_encode($_jobs-&gt;get_execute($_sql)));
  
              }catch(PDOException $e){
                  $app-&gt;response-&gt;status(500);
                  echo "Error: Descargando los datos " . $e-&gt;getMessage();
              }
          });
  
          $app-&gt;get('/profile/:user/:pass', function($_Nombre_USU = '', $_Clave_USU = '') use($app) {
              try{
                  $_jobs = new Jobs();
  
                  $_sql = 'SELECT u._id_PER, p._id_IMA, p.Nombre_PER, p.Apellidos_PER, p.Identificacion_PER, p.Telefono_PER, p.Celular_PER, p.Correo_PER, p.Sexo_PER, p.Direccion_PER, t.Nombre_TPO Tipo_PER, u.Nombre_USU, u.Clave_USU, u.SO_Plataforma_USU, u.Rol_USU, p.Creado_PER Actualizado_PER FROM Usuarios u INNER JOIN Personas p ON p._id = u._id_PER INNER JOIN Tipos t ON t._id = p._id_TPP ';
  
                  $_where = 'WHERE ';
  
                  if($_Nombre_USU != '') {
                      if($_Clave_USU != '') 
                          ($_where == 'WHERE ') ? $_sql .= $_where.'(Nombre_USU = "'.$_Nombre_USU.'") AND (Clave_USU = "'.$_Clave_USU.'")' : $_sql .= $_where.' AND (Nombre_USU = "'.$_Nombre_USU.'") AND (Clave_USU = "'.$_Clave_USU.'")';
                  }
  
                  $app-&gt;response-&gt;headers-&gt;set("Content-type", "application/json");
                  //$app-&gt;response-&gt;setHeader('Access-Control-Allow-Origin', '*');
                  $app-&gt;response-&gt;status(200);
                  $app-&gt;response-&gt;body(json_encode($_jobs-&gt;get_execute($_sql)));
              }catch(PDOException $e){
                  $app-&gt;response-&gt;status(500);
                  echo "Error: Descargando los datos " . $e-&gt;getMessage();
              }
          });
  });
  </code></pre>
  
  <p>If you want to try the service, use the following URL: <a href="http://skulapp.com/nuevo/service/get_profile/profile/eudes/5338eb5355db63e418c6b707ab00ccdf" rel="nofollow">http://skulapp.com/nuevo/service/get_profile/profile/eudes/5338eb5355db63e418c6b707ab00ccdf</a></p>