简体   繁体   English

从本地服务器请求JavaScript时,Rails收到CORS错误

[英]Rails getting CORS error when requesting javascript from the local server

I'm using head.js to load a dialog polyfill for browsers that don't support it. 我正在使用head.js为不支持它的浏览器加载对话框polyfill。 I've got head.js in my /app/assets/javascripts/application.js file and I'm trying to load the polyfill from /app/assets/javascripts/build/polyfills/dialog-polyfill.js But I keep getting the following cross origin error 我有head.js在我/app/assets/javascripts/application.js文件,我试图加载从填充工具/app/assets/javascripts/build/polyfills/dialog-polyfill.js但我不断收到以下交叉原点错误

ActionController::InvalidCrossOriginRequest in BaseController#index
Security warning: an embedded <script> tag on another site requested protected JavaScript. If you know what you're doing, go ahead and disable forgery protection on this action to permit cross-origin JavaScript embedding.

Rails.root: /Users/rich/IdeaProjects/test_project

Application Trace | Framework Trace | Full Trace
Request

Parameters:

{"path"=>"assets/javascripts/build/polyfills/dialog-polyfill.min","format"=>"js"}

Session Dump 会话转储

_csrf_token: "phRgTk+ckBBhFegpIu+mwvkIJzd57rt4T6XZUE8Wee4="
session_id: "7f5e825832ba66bdc94ea27ab930d04c"

Env Dump 环保转储

GATEWAY_INTERFACE: "CGI/1.1"
HTTP_ACCEPT: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
HTTP_ACCEPT_ENCODING: "gzip, deflate"
HTTP_ACCEPT_LANGUAGE: "en-us"
REMOTE_ADDR: "127.0.0.1"
REMOTE_HOST: "127.0.0.1"
SERVER_NAME: "localhost"
SERVER_PROTOCOL: "HTTP/1.1"

Are you not pulling build/polyfills/* into your application.js manifest already using 您是否正在将build / polyfills / *提取到已经使用过的application.js清单中

//= require_tree . // = require_tree。

? My understanding is that it's faster to render a single large CSS file than fetching multiple files. 我的理解是,呈现单个大型CSS文件比获取多个文件更快。 More info on manifest files here . 有关清单文件的更多信息,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM