2

Is there a general strategy for catching CORS failures in ember.js.

For example when one of the back-end servers is offline or is unreachable because the client no longer has network access. Ember-Data and Ember-Simple-Auth requests will both fail with something similar to:

Cross-Origin Request Blocked: The Same ... (Reason: CORS request failed)

I understand what the message means and I have the backends configured correctly - my question isn't about how to make it work it is how to catch the error when the server is offline (or I guess if a CORS configuration changed in production)

Question:

Is there a way for me to have a handler across the entire application so I can display an offline warning/message to the user?

Or Should I be handling it uniquely per each usage (e.g. a separate handler for authentication and one for each back-end data source)?

The default behavior, implementing nothing is that the request fails and the data doesn't get returned but it appears that there is not a straightforward way to catch it.

Angelo
  • 786
  • 8
  • 8
  • can you trace this a bit further to understand if it's simply a callback from RSVP that is throwing this failure? Thinking something like Ember.RSVP.on('error', function() {}) – Toran Billups Nov 09 '15 at 13:05
  • I am not sure where I should be looking for this level of detail - in the console I see the following which is just the top level catches (local server down, e.g.): `Content Security Policy: The page's settings observed the loading of a resource at http://127.0.0.1:5303/api/auth ("connect-src http://localhost:4200 http://127.0.0.1:5000 ws://localhost:49154 ws://0.0.0.0:49154 http://0.0.0.0:4200/csp-report"). A CSP report is being sent. Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:5303/api/auth. (Reason: CORS request failed).` – Angelo Nov 10 '15 at 07:40

0 Answers0