Pregunta

I have been able to implement a CORS response with a fetch().

However, when I look to save() a model using PUT have been unable to implement this. The response which comes back is

OPTIONS http://[external domain] 501 (Not Implemented)
XMLHttpRequest cannot load http://[external domain]. Origin http://127.0.0.1:8888 is not allowed by Access-Control-Allow-Origin.

Can anyone give me an example of how to change backbone sync to implement this? or is this even possible?

¿Fue útil?

Solución

When you do any action other than a GET using CORS you have to go through the pre-flight process as outlined in this question/answer: CORS - How do 'preflight' an httprequest? and also on this blog post: http://avalanche123.com/blog/2011/10/10/cross-domain-javascript-lessons-learned/

You have to make some extra steps beyond the easy GET CORS workflow.

Otros consejos

Have a look at easyXDM. It provides a simple interface for enabling backwards compatible CORS. I don't have any sample for how to implement Backbone.sync, but it should be pretty straight forward.

Hope this helps!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top