How to set access-control-allow-origin in webrick under rails?

后端 未结 6 684
广开言路
广开言路 2020-12-02 13:08

I have written a small rails app to serve up content to another site via xmlhttprequests that will be operating from another domain (it will not be possible to get them runn

6条回答
  •  自闭症患者
    2020-12-02 13:59

    Rails 3.1

    class ApplicationController < ActionController::Base
      protect_from_forgery
      after_filter :set_access_control_headers
    
      def set_access_control_headers
        headers['Access-Control-Allow-Origin'] = '*'
        headers['Access-Control-Request-Method'] = '*'
      end
    end
    

提交回复
热议问题