Ionic 2 CORS issue

Hey Guys,

Im running my API from Laravel and using the CORS package here

The config file reads as follows:

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

and i have added the CORS middleware to my routes

Everything works fine in Postman, my API returns me a token, but when i run my Ionic 2 app, im gettting the following

No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access. The response had HTTP status code 422

Ive also tried ionic upload and running it from my phone but still no luck.

Any help would be greatly appreciated.


Try this link that might helps you.

(if you are working on MAC machine)

or this

(if you are working on windows machine)


Ahhh that makes sense :slight_smile:

Thank you

Glad this solution work for you.

Happy Coding :wink:

look at this i solve it easily