Infinite redirect with connect.static in Node 0.5.6 on Windows #360

Closed
juandopazo opened this Issue Sep 10, 2011 · 2 comments

Comments

Projects
None yet
3 participants

Hi! When navigating to a URL that ends in / with the following server running on Node 0.5.6 on Windows, the static middleware makes an infinite redirect appending a slash to the URL every time.

var connect = require('connect'),
    server = connect.createServer(),
    pub = __dirname, '/www';

server.use(connect.static(pub));
server.listen(80);

This is happening when the path points to a directory, so the flow always lands on this part of the static middleware:

    } else if (stat.isDirectory()) {
      res.statusCode = 301;
      res.setHeader('Location', url.pathname + '/');
      res.end('Redirecting to ' + url.pathname + '/');
      return;
    }

The reason is very likely the latest change to fs.stat in Node 0.5.6. Anyway, the expected behavior would be that static looked for a index.html file and send its contents without modifying the url if it ends with a slash.

Raynos commented Sep 10, 2011

0.5.x is not supported.

I thought so, but I filed it just in case so you are aware of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment