{"id":8176,"date":"2015-11-29T08:33:48","date_gmt":"2015-11-29T08:33:48","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/29\/apigee-pre-flight-options-requests-open-source-projects-flightjs-flight\/"},"modified":"2022-08-30T15:02:58","modified_gmt":"2022-08-30T15:02:58","slug":"apigee-pre-flight-options-requests-open-source-projects-flightjs-flight","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/29\/apigee-pre-flight-options-requests-open-source-projects-flightjs-flight\/","title":{"rendered":"Apigee Pre-Flight Options Requests-open source projects flightjs\/flight"},"content":{"rendered":"<p>I create api proxies and check the box that says &#8220;Enable Direct Browser Access for Your API \u2014 Allow direct requests from a browser via CORS.&#8221; but my OPTIONS requests are still failing with :<\/p>\n<pre><code>{\n    \"fault\": {\n        \"faultstring\": \"Received 405 Response without Allow Header\",\n        \"detail\": {\n            \"errorcode\": \"protocol.http.Response405WithoutAllowHeader\"\n        }\n    }\n}\n<\/code><\/pre>\n<p>From what I understand about CORS Pre-Flight Options requests, the client first sends the OPTIONS request to the server as a safeguard for &#8220;safe&#8221; CORS. This request should return a response with the list of <em>request types<\/em> that are available.<\/p>\n<p><strong>My Question:<\/strong> How do I make it so that Apigee responds correctly to OPTIONS requests and <strong>does not pass the OPTIONS request to my api behind the proxy?<\/strong>. If it helps I have AngularJS javascript apps trying to communicate with my Apigee endpoint.<\/p>\n<p>Javascript errors:<\/p>\n<pre><code>OPTIONS http:\/\/api.example.com No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http:\/\/client.example.com' is therefore not allowed access.\n\nXMLHttpRequest cannot load http:\/\/api.example.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http:\/\/client.example.com' is therefore not allowed access. \n<\/code><\/pre>\n<p>Default &#8220;Add CORS&#8221; xml<\/p>\n<pre><code>\n    Add CORS\n    \n    \n    \n        \n            *\n            origin, x-requested-with, accept\n            3628800\n            GET, PUT, POST, DELETE\n        \n    \n    true\n    \n\n<\/code><\/pre>\n<p>Default Proxy Endpoints xml<\/p>\n<pre><code>\n\n    \n    \n    \n        \n        \n    \n    \n        \/v1\/cnc\n        default\n        secure\n    \n    \n        default\n    \n    \n        \n        \n    \n\n<\/code><\/pre>\n<p>Default Target Endpoint xml<\/p>\n<pre><code>\n\n    \n    \n    \n        \n        \n            \n                Add-CORS\n            \n        \n    \n    \n        http:\/\/api.example.com\/v1\/assets.json\n    \n    \n        \n        \n    \n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I create api proxies and check the box that says &#8220;Enable Direct Browser Access for Your API \u2014 Allow direct requests from a browser via CORS.&#8221; but my OPTIONS requests are still failing with : { &#8220;fault&#8221;: { &#8220;faultstring&#8221;: &#8220;Received 405 Response without Allow Header&#8221;, &#8220;detail&#8221;: { &#8220;errorcode&#8221;: &#8220;protocol.http.Response405WithoutAllowHeader&#8221; } } } From what I [&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-8176","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8176","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=8176"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8176\/revisions"}],"predecessor-version":[{"id":8558,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8176\/revisions\/8558"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}