These are chat archives for AngularClass/angular2-webpack-starter

11th
May 2016
Jyothi lakshmi R
@Jyothi406
May 11 2016 11:10

This error in Mozila :
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.uber.com/v1/products?latitude=12.9716&longtitude=77.5946. (Reason: missing token 'access-control-allow-headers' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channel).

This error is in Chrom:
XMLHttpRequest cannot load https://api.uber.com/v1/products?latitude=12.9716&longtitude=77.5946. Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response.

i am not sure it origin mismatch or token not assigned in the header, i am not using oauth i just want to authenticate with server token provided by the uber api server.

this is my code:

client.service.ts
getEstimatesForUserLocation (lat:number,lon:number) {

let endpoint = 'https://api.uber.com/v1/products';
let url  = `${endpoint}?latitude=${lat}&longtitude=${lon}`;
let headers = new Headers();

headers.append('Authorization', 'SERVER_TOKEN');//assigning my server token to header
headers.set('Access-Control-Allow-Origin', '*');
headers.get('Access-Control-Allow-Origin');
headers.append('Access-Control-Allow-Headers','x-requested-with, Content-Type, origin, authorization, accept, client-security-token');
headers.get('Access-Control-Allow-Headers');

return this.http.get(url, {headers})
  .map(res => res.json());

}
client.component.ts

getEstimatesForUserLocation() {
this._countryService.getEstimatesForUserLocation(this.lat, this.long )
.subscribe(
data=> this.row = data,
error =>this.error = "location" + this.lat + this.long + "invalid."
);

}

can any one please tell me server token which i am assigning here is correct?
note: i am using @angular/http package

webdev48
@webdev48
May 11 2016 18:29
I am on beta 11 using this web pack starter...everything seemed to be working until last week... I recently started getting the following on my console
'//@ sourceURL' and '//@ sourceMappingURL' are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead. and a lot of them warnings whenever the application bootstraps
what should i do to avoid these warnings ( other than upgrading to latest release )
Colin Kearns
@Ckearns1210
May 11 2016 18:43
I have got my project upgraded to RC 2 but the update must have broken something as I am now getting this error again: 90% optimize assetsError in bail mode: [default] /Users/Daily/Shortcut-Webpack/typings/browser/ambient/jquery/index.d.ts:3223:12 Subsequent variable declarations must have the same type. Variable '$' must be of type 'cssSelectorHelper', but here has type 'JQueryStatic'. and I cannot figure out how I fixed it the first time, does anyone know?
Graham Churchley
@gchurchley
May 11 2016 19:13
I'm using Karma to test my ng2 app. How do I force Karma to acquire plugins from the local [current] folder? I am seeing this debug message: Loading plugin C:\Program Files\nodejs\node_modules/karma-requirejs. Why is it looking in the "Program Files" folder?
Graham Churchley
@gchurchley
May 11 2016 19:28
Fixed my Karma issue with regard to global plugins. I did
npm uninstall -g karma-requirejs
So now there is no global version and Karma picks the local version in the current folder. This is NOT how I would expect it to work. Surely the local folder should take precedence.