My iisnode setup wont serve the static files

1.4k Views Asked by At

What is wrong with my setup? have in mind I use express.

web.config file :

<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>

and the app.js is as below :

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;
});

and the html has the classic layout like this:

<link rel="stylesheet" type="text/css" href="cssKtelVolouOsm.css">
<script type="text/javascript" src="javascriptKtelVolouOsm.js"></script>

and I get the following errors:

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 
1

There are 1 best solutions below

13
On BEST ANSWER

If those files actually exist under ./pro/Public then this is most likely caused by the use of relative URLs in your html. Try this instead.

<link rel="stylesheet" type="text/css" href="/cssKtelVolouOsm.css">
<script type="text/javascript" src="/javascriptKtelVolouOsm.js"></script>