0

I am getting this error with my Reacjs application with the production build.

Refused to execute script from 'https://www-xxxx.com/apps/someapp/settings/static/js/52.eebbab07.chunk.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

This error occurred due to URL change with client-side routing in my application. I used the following attribute in my package.json file.

  "homepage": ".",

The static files are located in https://www-xxxx.com/apps/someapp/ path. Is there a way to control this behaviour which happened with internal routing and the homepage attribute?

1 Answer 1

1

This error occurred because when the homepage attribute is defined, assets will be served relative to index.html. Then what happened was my application had internal routing implemented. So it broke the application because then the app is looking at static files in the wrong location.

Files were stored in the https://www-xxxx.com/static and my app was searching those files in https://www-xxxx.com/apps/someapp/settings/static/. As long as you have only one route like below https://www-xxxx.com/settings then you won't get any errors with relative way.

You can read this question as well. Using `"homepage"` in package.json, without messing up paths for localhost

I solved this error with a simple Nginx rewrite.

rewrite /static/(.*)$ /static/$1 break;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.