0

my website works fine on local host but when i upload it to heroku i get The resource from “https://websitename.herokuapp.com/Static/js/main.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). on all static files both css and javascript

index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />

    <!-- Google Font -->
    <link
      href="https://fonts.googleapis.com/css?family=Muli:300,400,500,600,700,800,900&display=swap"
    />
    <link
      rel="stylesheet"
      href="./Static/css/slicknav.min.css"
      type="text/css"
    />
    <link rel="stylesheet" href="./Static/css/style.css" type="text/css" />

    <title>React App</title>
  </head>
  <body>
    <div id="root"></div>

    <script
      src="./Static/js/jquery.slicknav.js"
      type="text/javascript"
    ></script>
    <script src="./Static/js/main.js" type="text/javascript"></script>
  </body>
</html>

i had to remove some of them from my post so they could fit.

adel bouakaz
  • 311
  • 2
  • 11
  • Are you using whitenoise to manage your static files? – Jarad May 15 '21 at 15:57
  • yes, forgot to mention it. – adel bouakaz May 15 '21 at 16:08
  • Did you see this [question](https://stackoverflow.com/questions/62555499/django-react-the-resource-was-blocked-due-to-mime-type-text-html-mismatch)? Also, have you ran collectstatic? – Jarad May 15 '21 at 17:46
  • yes i saw it, but i did not help. – adel bouakaz May 15 '21 at 18:01
  • a possible mistake i made while following the deploy tutorial is the fact that the new white noise version does not have `whitenoise.django.gzipmanifeststaticfilesstorage` option so i replaced it with `whitenoise.storage.CompressedManifestStaticFilesStorage` – adel bouakaz May 15 '21 at 18:17
  • ok, so the problem was that i had `/build` in `.gitignore` so most of the errors are gone except the ones for `static/js/2.956d09bb.chunk.js` and `static/css/2.c7c4a6ed.chunk.css` which were created automatically when i ran npm run build – adel bouakaz May 15 '21 at 19:45

0 Answers0