我的设置有什么问题?请记住我使用快递。
web.config文件:
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
,app.js如下:
var express = require('express');
var app = express();
var server = http.createServer(app).listen(process.env.port);
app.use(express.static(__dirname + '/pro/Public'));
app.get('/pro',function(req,res) {
res.sendfile(__dirname + '/yoyo.html');
res.end;
});
并且html具有如下经典布局:
<link rel="stylesheet" type="text/css" href="cssKtelVolouOsm.css">
<script type="text/javascript" src="javascriptKtelVolouOsm.js"></script>
我收到以下错误:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/cssKtelVolouOsm.css
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/javascriptKtelVolouOsm.js
答案 0 :(得分:2)
如果这些文件实际存在于./pro/Public
下,那么这很可能是由于在html中使用相对URL造成的。试试这个。
<link rel="stylesheet" type="text/css" href="/cssKtelVolouOsm.css">
<script type="text/javascript" src="/javascriptKtelVolouOsm.js"></script>