如何解决拒绝从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 举报,一经查实,本站将立刻删除。