CORS problem with Ionic and angular 2 "No 'Access-Control-Allow-Origin' header is present on the requested resource"

I have a problem with getting data from an api on ionic 2 app.

that’s what i get


my code to grab the data

import { Injectable } from ‘@angular/core’;
import { Http } from ‘@angular/http’;
import ‘rxjs/add/operator/map’;

Generated class for the Service provider.

for more info on providers and Angular 2 DI.
export class NewsService {
data: any;
private news;

constructor(private http: Http) { = null;

load() {
if ( {
// already loaded data
return Promise.resolve(;

// don't have the data yet
return new Promise(resolve => {
  // We're using Angular Http provider to request the data,
  // then on the response it'll map the JSON data to a parsed JS object.
  // Next we process the data and resolve the promise with the new data.
    .map(res => res.json())
    .subscribe(data => {
      // we've got back the raw data, now generate the core schedule data
      // and save the data for later reference = data;



any help please

1# update , i found temporary solution by installing this plugin on chrome

Allow-Control-Allow-Origin: *


It happens when you are running serve. Ionic CLI support proxy to pass this problem. Add this to ionic.config.json:

"proxies": [
        "path": "/api",
        "proxyUrl": ""

Now you can use http://localhost:8100/api/ISteamNews


Thank you :smile_cat:

How do you get around cors if your ionic 2 app is HOSTED ON THE CLOUD, providers such as, Azure, and AWS ?

Thanks, Rich

Hi , you have to use proxies like this

“proxies”: [
“path”: “/api”,
“proxyUrl”: “

1 Like

Thank you so much :)).

If you use php on server then write header(‘Access-Control-Allow-Origin: *’); in your controller and its done

Sorry I am having the same issue here.
i have included the proxy in my ionic.config.json, but i ma still having same issue,

My question is after I put the proxy in my ionic.config.json file , how do i use it in my http request ?
i meant how do I call the url in my http request, Will I be writing my external api url like the below
or I will change the to localhost:8100?

below is my config file
"proxies": [
“path”: “/you”,
“proxyUrl”: “

below is my http request

var login = “http://localhost/you/database/me.php”;

return this.http.get( login)
.map(res => res.json()); // Mapping the response to json format

Hi Rich,
I have exactly the same question and I am facing the issue with aws hosted website.Have you found a solution.