[Webpack] Threejs Editor의 serviceWorker 경로 문제 해결

옥영빈·2022년 12월 6일
0

threejs

목록 보기
1/7

에러 발생

A bad HTTP response code (404) was received when fetching the script.
index.js?15bb:21 Service Worker failed to install TypeError: Failed to register a ServiceWorker for scope ('http://localhost:8080/') with script ('http://localhost:8080/sw.js'): A bad HTTP response code (404) was received when fetching the script

stackoverflow를 찾아본 결과
1. sw.js 파일이 html파일과 같이 있어야 함(이미 같은 위치)
2. src라는 폴더 명 보단 public이라는 폴더 명을 인식한다 라고 함

참고 자료

https://stackoverflow.com/questions/30336685/404-error-when-trying-to-register-serviceworker

https://stackoverflow.com/questions/69208716/registering-a-service-worker-gives-404-in-webpack-project

src폴더 명 변경 전

public로 폴더 명 변경 후

폴더 명을 public로 변경 후 에러가 사라짐!!!!

결론

sw.js의 404에러는 webpack의 기본 폴더 인식(src -> public)의 문제인 듯?

profile
webGL개발 초보

0개의 댓글