{"id":7521,"date":"2015-07-18T03:26:25","date_gmt":"2015-07-18T03:26:25","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/07\/18\/satellizer-causes-angular-to-pre-flight-all-of-my-rest-queries-with-an-options-request-open-source-projects-sahat-satellizer\/"},"modified":"2015-07-18T03:26:25","modified_gmt":"2015-07-18T03:26:25","slug":"satellizer-causes-angular-to-pre-flight-all-of-my-rest-queries-with-an-options-request-open-source-projects-sahat-satellizer","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/07\/18\/satellizer-causes-angular-to-pre-flight-all-of-my-rest-queries-with-an-options-request-open-source-projects-sahat-satellizer\/","title":{"rendered":"Satellizer causes Angular to pre-flight ALL of my rest queries with an OPTIONS request-open source projects sahat\/satellizer"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1b39b5384ac2c877a8fc04eee3c2f840?s=128&amp;d=identicon&amp;r=PG\" \/> <strong>Yves<\/strong><\/p>\n<p>After looking through the code and studying Angualr&#8217;s httpProvider I realized that Sateliizer is intercepting every single request using httpProvider&#8217;s interceptors array and adding the following:<\/p>\n<pre><code>var token = localStorage.getItem(tokenName);\nif (token &amp;&amp; config.httpInterceptor) {\n  token = config.authHeader === 'Authorization' ? 'Bearer ' + token : token;\n  httpConfig.headers[config.authHeader] = token;\n}\n<\/code><\/pre>\n<p>So that every single request gets an Authorization header. Since I actually have only ONE request that needs an authorization header I modified the conditional statement:<\/p>\n<pre><code>if (token &amp;&amp; config.httpInterceptor &amp;&amp; httpConfig.auth===true) {\n<\/code><\/pre>\n<p>and then in my $http.get for the single service that actually needs authorization I add:<\/p>\n<pre><code>        var config = {auth: true};\n        $http.get(googleUrl, config)           \n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Yves After looking through the code and studying Angualr&#8217;s httpProvider I realized that Sateliizer is intercepting every single request using httpProvider&#8217;s interceptors array and adding the following: var token = localStorage.getItem(tokenName); if (token &amp;&amp; config.httpInterceptor) { token = config.authHeader === &#8216;Authorization&#8217; ? &#8216;Bearer &#8216; + token : token; httpConfig.headers[config.authHeader] = token; } So that every [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7521","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7521"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7521\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}