Rails应用在部署到heroku后没有加载Arbor.js

Rails app not loading Arbor.js once deployed to heroku

本文关键字:加载 Arbor js heroku 应用 部署 Rails      更新时间:2023-09-26

我们正在构建一个rails应用程序,并使用Arbor.js在rails应用程序的web页面上显示节点图,它在本地主机上工作得很好,但是当我们部署时,我们得到以下错误。

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标签,上面写着:

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

我在让它在Heroku上运行时遇到了很大的问题,我找不到足够的文档。什么好主意吗?

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