Ionic 3 + Standard. Problem with http request on server

Asked

Viewed 136 times

0

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


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

My Cors.php configuration file is as follows:

<?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 Prior method that makes the request on Ionic:

set_ajudado(dados):Promise<any>
  {
    return this.http.post(this.url, dados).toPromise().then(function(data){
      return  data; 
   });
  }
  • You have disabled token validation?

  • Yes, but I figured out the problem... 000webhost does not accept options requests on its free plan. I was able to solve the problem by making the Lockable available on local network. Still, thanks for the help!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.