개발/나의 오류 일지

[나의 오류 일지] MIME type ('text/html') is not executable

hanuuny 2024. 7. 28. 23:05

React Router에서 Path Parameter로 동적 라우팅을 처리하면 계속 다음과 같은 에러가 발생하며 페이지가 제대로 표시되지 않았다.

Refused to execute script from 'http://localhost:3000/path/main.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

 

어디선가 경로 설정을 잘못해서 생긴 문제라는 건 직감할 수 있었지만, 서치를 해도 너무 다양한 상황이 존재해 정확한 해결 방법을 파악하기 어려웠다.


output: {
  publicPath: '/',
  ...
}

 

나의 경우 webpack.config.js에 publicPath를 설정하여 문제를 해결하였다.

 

 

👇🏻 참고

https://stackoverflow.com/questions/49617440/mime-type-text-html-is-not-executable-and-strict-mime-type-checking-is-enab

 

MIME type ('text/html') is not executable, and strict MIME type checking is enabled

Refused to execute script from 'http://localhost:8080/edit/bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. I am using react-router and I...

stackoverflow.com