R Shiny-如何添加访问控制允许来源:*

问题描述:

如何将Access-Control-Allow-Origin: *添加到有光泽的应用程序?

How can I add Access-Control-Allow-Origin: * to a Shiny app?

我想通过以下ajax调用Shiny应用程序:

I want to call the Shiny app via ajax below:

<div id='include-from-outside'></div>
<script type='text/javascript'>
    $.get('//127.0.1.1:3838/', {}, function(data, status, xhr) {
        var updatedData = data.replace(/\/(images|stylesheets|javascripts|vendors|fonts)+/g, "http://127.0.1.1:3838/$1");

        $('#include-from-outside').html(updatedData);
    });
</script>

但是我得到这个错误:

请求的请求上没有'Access-Control-Allow-Origin'标头 资源.因此,不允许访问来源" http://127.0.1.1 ".

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.1.1' is therefore not allowed access.

有什么想法吗?

我遇到了同样的问题.

简单的方法是只在Google chrome中添加扩展名,以允许使用CORS进行访问.

The easy way is to just add the extension in google chrome to allow access using CORS.

( https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=zh-CN )

只要您想允许不访问任何"access-control-allow-origin"标头请求,就只需启用此扩展名.

Just enable this extension whenever you want allow access to no 'access-control-allow-origin' header request.