Refused to execute script from packs/js/index-662807e73049021453fe.js' because its MIME type ('text/html')

370 Views Asked by At

Im deploying a website with aws ec2 instance using react/rails. When running the server through rails s -e production i get this error

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.

my 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>

Ive been looking for an answer for a week now. Any help would be greatly appreciated.

Update:

my routes to catch all routes in routes.rb

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

and that points to homepage view

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

There are 0 best solutions below