lundi 9 novembre 2015

Catching the CORS preflight failure in ember.js

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.




Aucun commentaire:

Enregistrer un commentaire