HTTP POST not found 404 ionic with sails.js

I have an ionic app which works well with ionic serve when I make POST orGET requests to my localhost , bt when I make ionic uild android and then ionic run android I always get a 404 POST not found, I tried almost everything. I have added the plugin whitelist and put in my config.xml

  <content src="index.html"/>
  <access origin="*"/>
  <allow-intent href="*"/>
  <allow-navigation href="*"/>

in index html I tried these meta(commented one and uncommented the other)

<!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self'> -->

<meta http-equiv="Content-Security-Policy" content="default-src 'self' * ws://localhost:35729 data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *;script-src 'self' localhost:35729 'unsafe-eval' 'unsafe-inline';">

I use sails as the backend , I think cors are well configured:

module.exports.cors = {

  allRoutes: true,
  origin: '*',

  credentials: true,

  methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',


  headers: 'content-type, access-control-allow-origin, authorization'
  };

At the beginning of app.js I have this config

  angular
.module('frontend', [
  'ionic', 'ionic.service.core',
  'frontend.core',
  'ionic.service.analytics',
  //'cacheapp',
  //'cachemodule',
  'ionic-cache-src',
  'formlyIonic',
  'pascalprecht.translate',
  'angularMoment',
  'ionic.components',
  'ngFacebook',
  'translate.app',
  'translate.form',
  'angular-cache',
  'ngCordova',
  'gettext',
  'module.user',
  'module.gallery'
])
.constant('AccessLevels',{
      anon: 0,
      user: 1,
      admin: 2
})
.constant('BackendConfig',{
  url: "http://api-test-dev.com:1337",
  //url: "http://ip_of_my_phone:1337"
  //url: "10.0.2.2"
  //url: "10.0.2.2:1337"
  //url:"http://ip_of_my_phone"
  //url:"http://ip_of_my_wifi"
  //url:"http://ip_of_my_wifi:1337"
})

commented urls are all options I tried : I got them with ifconfig , when it was the case of my phone I disabled the wifi on my computer and used the connection usb of my phone(so the ip was usb0 in ifconfig). I also tried the url “http://localhost:1337” in app.js using port forwarding on chrome://inspect/#devices (by assigning to port 1337 of my device the localhost:1337 of my computer)

But all configuration always give the error POST 404 not found

Any ideas?

1 Like