문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top