Node.js를 서버로 사용하고 있으며 JS 및 CSS 파일 제공에 문제가 있습니다. 웬일인지 index.html
는 그들을 발견 할 수 없을 것입니다.Node.js가 내 파일을 찾을 수없는 이유
내 파일 시스템 구조 : : 내 브라우저를로드 할 때이 오류가 얻을
public
css
main.css
normalize.css
js
main.js
upload.js
plugins.js
views
index.html
server.js
HTML
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="../public/site.webmanifest">
<link rel="apple-touch-icon" href="../public/icon.png">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="../public/css/normalize.css">
<link rel="stylesheet" href="../public/css/main.css">
<script src="../public/js/vendor/modernizr-3.5.0.min.js"></script>
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js">
</script>
<script src="../public/js/plugins.js"></script>
<script src="../public/js/main.js"></script>
<script src="../public/js/upload.js"></script>
</head>
server.js를
var express = require("express");
var app = express();
var path = require("path");
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', function(req, res){
res.sendFile(path.join(__dirname, 'views/index.html'));
});
내 생각 엔 server.js
에서 공용 폴더를 잘못 처리하고 있습니다. 내가 얻을 GET/public 브라우저에서 해당 폴더에 직접 액세스하려고 시도 할 수 없습니다. 어떤 전문가가 여기 도와 줄 수 있니?