Ruby on rails 没有';访问控制允许原点';与斯威格和福尔曼Rails服务器
我的服务器当前运行速度为0.0.0.0:5100。当我尝试访问我的Swagger文档时,控制台中出现以下错误:Ruby on rails 没有';访问控制允许原点';与斯威格和福尔曼Rails服务器,ruby-on-rails,swagger,Ruby On Rails,Swagger,我的服务器当前运行速度为0.0.0.0:5100。当我尝试访问我的Swagger文档时,控制台中出现以下错误: XMLHttpRequest cannot load http://0.0.0.0/api/v1/types.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://0.0.0.0:5100' is therefore not allowed a
XMLHttpRequest cannot load http://0.0.0.0/api/v1/types.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://0.0.0.0:5100' is therefore not allowed access.
我想知道为什么会这样。以下是我在index.html中的招摇过市配置:
$(function () {
window.swaggerUi = new SwaggerUi({
url: "/api-docs.json",
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
log("Loaded SwaggerUI");
if(typeof initOAuth == "function") {
/*
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
appName: "your-app-name"
});
*/
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none"
});
您是否启用了对web服务的支持?要求CORS的支持才能让它工作。您收到的错误消息与我在添加CORS支持之前在Grails项目上收到的消息完全相同。允许控制允许源代码:浏览器中添加了chrome store上的扩展 注意:一旦您完成工作,请禁用此选项,因为youtube将无法使用启用选项