Hi, i have a CORS issue with google directions API. During development i had set a proxy to fix the issue so it worked but now that i’m going to publish my app i set the real api url (https://maps.googleapis.com/maps/api/directions) and it’s giving me CORS error.
I have a simple provider which from user’s location and place’s location gives the distance between them (code bellow) :
getDistance(lat1:number, lng1:number, lat2:number, lng2:number): Observable<any>{
return this.http.get(AppConfig.apiDevDIR + '/json?origin='+lat1+','+lng1+'&destination='+lat2+','+lng2+'&key=XXXXXXXXXXX')
// ...and calling .json() on the response to return data
.map((res:Response) => res.json())
//...errors if any
.catch((error:any) => Observable.throw(error.json().error || 'Server error'));
}
Everything works well when i use proxy but i have CORS issue when using the real url for production.
Anyone already find a solution for something like this ?