我们正在构建一个Rails应用程序,并使用Arbor.js在Rails应用程序的网页上显示一个节点图,并且在localhost上运行良好,但是在部署时会出现以下错误。

Resource interpreted as Script but transferred with MIME type text/html: "http://www.thoughtly.io/users/9/categories". 29:11
Refused to execute script from 'http://www.thoughtly.io/public/assets/arbor.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. 29:1
arbor.js/web-workers
Object {integrator: "verlet", repulsion: 1000, stiffness: 30, friction: 40, dt: 0.02…}
 VM414:1
Resource interpreted as Script but transferred with MIME type text/html: "http://www.thoughtly.io/users/9/categories". application-7588a131d5b5b403e30855abe426e8c5.js:11681
physics:
ErrorEvent {error: null, colno: 1, lineno: 1, filename: "http://www.thoughtly.io/public/assets/arbor.js", message: "Uncaught SyntaxError: Unexpected token <"…}


我们需要在layout.html.erb中带有脚本标签的脚本要求其内容如下:

  <script type="application/javascript" src="/public/assets/arbor.js"></script>


我在使其在Heroku上运行时遇到了很多问题,我找不到足够的文档。有任何想法吗?

最佳答案

如果尝试直接在浏览器中加载http://www.thoughtly.io/public/assets/arbor.js,则会将您重定向到http://www.thoughtly.io/。这意味着script标记正试图像解析Javascript文件一样解析HTML页面(这会导致Unexpected token <错误。请检查控制器中是否有任何before_filter导致了重定向。

09-16 23:00