• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 Node.js, Express 게시판 응답.sendFile(__dirname +'/index.html')에서 css랑 js랑 png

응답.sendFile(__dirname +'/index.html')에서 css랑 js랑 png

2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 글쓴이
  • #8674

    홍정표
    참가자

    응답.sendFile(__dirname +'/index.html')를 하여 html파일을 브라우저로 보냈는데,

    index.html에 연결한 index.css와 index.js와 img.png 가 로드가 안됩니다.

     

     

    코드는 이렇게 작성했습니다.

     

    //app.js

    app.get('/', function(요청, 응답) {

    응답.sendFile(__dirname +'/index.html')

    });

     

    //index.html 

    <link rel="icon" type="./image/png" href="img.png">
        <link rel="stylesheet" type="text/css" href="index.css">
        <script type="text/Js" src="index.js" defer></script>

     

    //console의 오류사항

    Refused to apply style from 'http://localhost:3000/index.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enable

    Failed to load resource: the server responded with a status of 404 (Not Found)

     

    //결과적으로 html만 브라우저에 표현되고, css랑 js랑 png는 표현이 안됩니다.

     

    도와주세요 선생님!

    #8677

    codingapple
    키 마스터

    일단 서버파일에 app.use(express.static 어쩌구를 잘 해놨는지 확인합시다 

    그리고 rel이나 type 둘 중 하나 삭제해봅시다 

2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠