Ionic 3 + laravel. Problem with http request on server

0

Edit: Solution 000webhost does not accept ' options ' requests in your free plan. I was able to solve the problem by making the laravel available in local network with the function php artisan serve --host=IP --port=8000

I'm developing a hybrid app with Ionic 3 and Laravel as Back-end. I had to host the backend on an online server (000webhost) to do some in-app testing, that's when it started my problems. Before hosting, using my computer as a server (localhost), I was able to make any kind of request through Ionic providers. Using the webhost hosting, I can only make GET requests, any other type of request of the MethodNotAllowedHttpException error. Trying to do the same type of request using the postman it is processed successfully.

My cors.php configuration file looks like this:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Laravel CORS
    |--------------------------------------------------------------------------
    |
    | allowedOrigins, allowedHeaders and allowedMethods can be set to array('*')
    | to accept any value.
    |
    */

    'supportsCredentials' => false,
    'allowedOrigins' => ['*'],
    'allowedOriginsPatterns' => [],
    'allowedHeaders' => ['*'],
    'allowedMethods' => ['GET', 'POST', 'PUT', 'DELETE'],
    'exposedHeaders' => [],
    'maxAge' => 0,

];

The route I'm trying to access:

Route::post ('ajudado/', 'AjudadoController@set_ajudado');

And the provider method that makes the request in the ionic:

set_ajudado(dados):Promise<any>
  {
    return this.http.post(this.url, dados).toPromise().then(function(data){
      return  data; 
   });
  }
    
asked by anonymous 29.05.2018 / 05:30

0 answers