Easy CORS AngularJS With Rails
Setting Up CORS is quite simple with angularjs and rails.
You are going to have to edit both the frontend and backend.
Frontend Angular Portion:
For the frontend portion, all you have to do is inject $httpProvider into your config and add 2 lines of code. See below for an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Rails Backend Portion:
For the rails back-end portion, start by adding the rack-cors gem to your gemfile. Then bundle.
After that, just edit your config/application.rb
1 2 3 4 5 6 7 8 9 10 11 |
|
Restart your app and CORS should now be enabled!