트러블슈팅
[nginx] 'application/octet-stream' 오류
KidAnt
2024. 10. 23. 14:16
발단 및 전개
- React 로 이루어진 index.html 파일을 nginx.conf 설정파일을 통해 연결시켜 주었으나 페이지가 정상적으로 출력되지 않는 문제 발생
Failed to load module script: Expected a JavaScript module script but the server
responded with a MIME type of "application/octet-stream".
Strict MIME type checking is enforced for module scripts per HTML spec.
- 개발자 모드를 통해 출력창의 경고를 확인했을 떄 위와 같은 경고가 뜸
https://github.com/storybookjs/storybook/issues/20157
- 검색 후에 위의 링크를 참고하여 nginx.conf 설정값의 문제인것을 확인
해결
- 기존 디폴트 값으로 "default_type application/octet-stream"로 설정되어 있어 바이너리 데이터 형식으로만 인식하는 것으로 판단
- 해당 부분을 주석처리하고 새로 타입을 설정해줄 필요성 있음
http {
include mime.types;
#default_type text/html html;
types {
application/javascript js mjs;
}
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
- 위와 같이 변경 후 서비스 재시작
- 정상 출력 확인
- 이제 추가적인 빌드을 통해 창을 완성시키기만 하면 된다.