Prepend AngularJS JSON vulnerability protection string ")]}',\n" to all JSON responses. See https://docs.angularjs.org/api/ng/service/$http.
Rack
Add to your Gemfile:
gem 'angularjs_json_middleware'
Or lock it to the current backwards compatible version:
gem 'angularjs_json_middleware', '~> 0.0.1'
Add the middleware to the stack.
For general use add it to your config.ru
.
use AngularjsJsonMiddleware
For rails add it to config/application.rb
.
class Application < Rails::Application
...
config.middleware.use AngularjsJsonMiddleware
...
end
The MIT License (MIT)