拒绝从packs / js / index-662807e73049021453fe.js'执行脚本,因为其MIME类型'text / html'

问题描述

我使用react / rails部署带有AWS EC2实例的网站。 通过rails -e production运行服务器时 我收到此错误

Refused to execute script from 'http://<ip-address>/packs/js/index-662807e73049021453fe.js' because its MIME type ('text/html') is not executable,and strict MIME type checking is enabled.

我的application.erb.html


<!DOCTYPE html>
<html>
  <head>
    <title>Production server</title>
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>
    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
    <%= stylesheet_link_tag    'application',media: 'all','data-turbolinks-track': 'reload' %>
    <%= javascript_pack_tag 'application','data-turbolinks-track': 'reload' %>
    <%= javascript_pack_tag 'index' %>
  </head>

  <body>
    <%= yield %>
  </body>
</html>

我已经在寻找答案一个星期了。 任何帮助将不胜感激。

更新:

我的路线以捕获route.rb中的所有路线

 root 'homepage#index'
  get ':path',to: 'homepage#index',format: false

这指向主页视图

 <%= javascript_pack_tag 'index' %>
 <%= react_component("App",{prerender: true}) %>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...