문제

Im trying to create a javascript frontend whom should communicate with my rails backend. I figured installing Middleman would solve the annoying errors:

XMLHttpRequest cannot load http://localhost:3000/groups.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4567' is therefore not allowed access. 

Unfortunately it doesn't. I'm assuming because they're not on the same ports.

Is there a 'quick' fix for this; Or should I just add headers to my Rails project to avoid getting the XSS errors?

도움이 되었습니까?

해결책

Installing Rack-Cors on your Rails backend is your best bet to resolving your 'Access-Control-Allow-Origin' errors.

Running on the same ports wouldn't solve this straight out the bag as its a security constraint of cors and Middleman would'nt either.

Put simply to access groups.json you will need some form of Cors Headers present on the server

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