<bdo id='cPAmD'></bdo><ul id='cPAmD'></ul>

        <i id='cPAmD'><tr id='cPAmD'><dt id='cPAmD'><q id='cPAmD'><span id='cPAmD'><b id='cPAmD'><form id='cPAmD'><ins id='cPAmD'></ins><ul id='cPAmD'></ul><sub id='cPAmD'></sub></form><legend id='cPAmD'></legend><bdo id='cPAmD'><pre id='cPAmD'><center id='cPAmD'></center></pre></bdo></b><th id='cPAmD'></th></span></q></dt></tr></i><div id='cPAmD'><tfoot id='cPAmD'></tfoot><dl id='cPAmD'><fieldset id='cPAmD'></fieldset></dl></div>
      1. <tfoot id='cPAmD'></tfoot>

        <small id='cPAmD'></small><noframes id='cPAmD'>

      2. <legend id='cPAmD'><style id='cPAmD'><dir id='cPAmD'><q id='cPAmD'></q></dir></style></legend>

        如何在rails下的webrick中设置access-control-allow-orig

        时间:2023-09-03
          <bdo id='2fJWa'></bdo><ul id='2fJWa'></ul>
            <tbody id='2fJWa'></tbody>

            1. <small id='2fJWa'></small><noframes id='2fJWa'>

                <legend id='2fJWa'><style id='2fJWa'><dir id='2fJWa'><q id='2fJWa'></q></dir></style></legend>

                <i id='2fJWa'><tr id='2fJWa'><dt id='2fJWa'><q id='2fJWa'><span id='2fJWa'><b id='2fJWa'><form id='2fJWa'><ins id='2fJWa'></ins><ul id='2fJWa'></ul><sub id='2fJWa'></sub></form><legend id='2fJWa'></legend><bdo id='2fJWa'><pre id='2fJWa'><center id='2fJWa'></center></pre></bdo></b><th id='2fJWa'></th></span></q></dt></tr></i><div id='2fJWa'><tfoot id='2fJWa'></tfoot><dl id='2fJWa'><fieldset id='2fJWa'></fieldset></dl></div>
                • <tfoot id='2fJWa'></tfoot>
                • 本文介绍了如何在rails下的webrick中设置access-control-allow-origin?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我编写了一个小型 Rails 应用程序,通过 xmlhttprequests 向另一个站点提供内容,该应用程序将从另一个域运行(不可能让它们在同一服务器上运行).我知道我需要在我的 rails 服务器上设置 access-control-allow-origin 以允许请求网页访问此材料.

                  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 running on the same server). I understand I will need to set access-control-allow-origin on my rails server to allow the requesting web page to access this material.

                  关于如何使用 Apache 执行此操作的文档似乎相当完备,这可能是我在部署站点后将使用的服务器.虽然我正在开发,但我希望只使用 webrick,就像我习惯使用 rails 一样.有没有办法配置 webrick 以在 rails 中提供适当的 http 标头?

                  It seems fairly well documented how to do this with Apache and this is probably the server I will use once I deploy the site. While I am developing though I hope to just use webrick as I am used to doing with rails. Is there a way of configuring webrick to provide the appropriate http header within rails?

                  推荐答案

                  如果您使用的是 Rails 2,只需将其添加到您的应用程序控制器.

                  If you're on Rails 2 just add this to your application contoller.

                  before_filter :set_access
                  
                  def set_access
                    @response.headers["Access-Control-Allow-Origin"] = "*"
                  end
                  

                  显然将 "*" 更改为不那么开放的东西是个好主意.

                  Obviously changing "*" to something a little less open would be a good idea.

                  这篇关于如何在rails下的webrick中设置access-control-allow-origin?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何检测 JavaScript 中 XMLHttpRequest() 的跨域 (CORS) 下一篇:如何在 react.js 中允许 CORS?

                  相关文章

                  最新文章

                • <legend id='BNeTK'><style id='BNeTK'><dir id='BNeTK'><q id='BNeTK'></q></dir></style></legend>

                  • <bdo id='BNeTK'></bdo><ul id='BNeTK'></ul>

                  <tfoot id='BNeTK'></tfoot>

                      <small id='BNeTK'></small><noframes id='BNeTK'>

                      <i id='BNeTK'><tr id='BNeTK'><dt id='BNeTK'><q id='BNeTK'><span id='BNeTK'><b id='BNeTK'><form id='BNeTK'><ins id='BNeTK'></ins><ul id='BNeTK'></ul><sub id='BNeTK'></sub></form><legend id='BNeTK'></legend><bdo id='BNeTK'><pre id='BNeTK'><center id='BNeTK'></center></pre></bdo></b><th id='BNeTK'></th></span></q></dt></tr></i><div id='BNeTK'><tfoot id='BNeTK'></tfoot><dl id='BNeTK'><fieldset id='BNeTK'></fieldset></dl></div>