originally posted in:BungieNetPlatform
Hey guys,
I was reworking my AngularJS project that fetches my destiny info to contain my api key. however, adding this custom header seems to break my app.
I've been forced to use a proxy service (was using http://crossorigin.me/ but tried heruko as well) so my app can run flawless, however, as soon as I include my api key header i'm running into the CORS issue again since neither services seem to forward my custom header (or when i include my custom header they seem to not include their own CORS headers).
Anyone else stumble onto this issue? able to get past it?
If not I guess I'll have to see if i can setup another fix for the issue. just wanted to keep with angularJS for learning purposes for myself :)
-
We actually run our app on Angular and Heroku so hopefully I can help. For local development we use the livereload proxy [url]https://github.com/SteffanLong/DestinyTrialsReport/blob/master/Gruntfile.js#L282[/url] Its set up so if we send a request to our app at [b]/bungie/Destiny/SearchDestinyPlayer/1/Deej%20BNG/[/b] the proxy rewrites that to [b]http://bungie.net/Platform/Destiny/SearchDestinyPlayer/1/Deej%20BNG/[/b] for Heroku we write the server.js in the gruntfile [url]https://github.com/SteffanLong/DestinyTrialsReport/blob/master/Gruntfile.js#L93[/url] which ends up looking like this [url]https://gist.github.com/v-fedorov/1b06cb360fa72d2a08ed#file-server-js-L38[/url]. You would need to set the API key as a Heroku env variable [b]BUNGIE_API[/b]
-
Thx for the replies guys. I must be doing something wrong. Will take a look at the links once I turn on my development laptop :-) i'm sure i'll get it up an running with this help. Was thinking about turning my raspberry pi into a webserver.
-
The only way is to make use of a proxy as you have been, or move your application to a context where it's less restricted. Setting up a simple local web server like nginx with PHP to route your JavaScript requests through will work well as a proxy (at least for playing with your code), and a browser plugin, extension, or add-on will have elevated permissions to make requests to wherever it's permitted to. Personally I'd go with the browser extension given what you've said, but it really depends on what you're aiming to do.