0
我正在運行expressjs
作爲本地服務器。我得到這樣的錯誤......這裏有什麼錯誤?以MIME類型text/html傳輸時,從expressjs中獲取錯誤
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:3000/js/lib/bootstrap/dist/css/bootstrap.min.css".
localhost/:11 Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:3000/js/lib/angular/angular.min.js".
localhost/:10 Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:3000/js/lib/jquery/dist/jquery.min.js".
localhost/:12 Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:3000/js/scripts/app.js".
這裏是我的html:
<!DOCTYPE html>
<html ng-app="myNewApp">
<head>
<meta charset="utf-8"> //i already declared the content type here.
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My New App!</title>
<link rel="stylesheet" href="/js/lib/bootstrap/dist/css/bootstrap.min.css">
</head>
<body>
<script src="/js/lib/jquery/dist/jquery.min.js"></script>
<script src="/js/lib/angular/angular.min.js"></script>
<script src="/js/scripts/app.js"></script>
</body>
</html>
我server.js
:
var express = require("express"),
app = express();
app
.use(express.static(__dirname + 'public'));
app
.get('*', function (req, res) {
res.sendfile('public/main.html');
})
app.listen(3000);
爲什麼'app.get('*',...'而不是'app.get('/',...'? – Itay
我猜兩者都是一樣的......'*'小心點什麼...... – 3gwebtrain
我不這麼認爲,試着替換它並看看 – Itay