Redirecting to // - connect.static bug on Windows #427

alessioalex opened this Issue Nov 28, 2011 · 8 comments


None yet
7 participants

When using connect.static on Windows (with Express), when visiting http://localhost it will show you:

Redirecting to //

even though you have the '/' route defined. I managed to find a workaround for this by using 'redirect: false' as an option, but this is a bug as far as I can tell (on Linux I never got that).

Note: I did not have anything except a txt file in the public folder. (so no index.html there)


tj commented Nov 28, 2011

thanks i'll add a test case for this in a bit and get it covered

andihit commented Dec 3, 2011

Same problem here, but in my case, I have an index.html.
I investigated a bit, and the issue lies in this line:

if ('/' == path[path.length - 1]) path += 'index.html';

in lib/middleware/static.js.
Because node's path.join uses \ on windows, we'll need an check like this

var pathsep = process.platform === 'win32' ? '\\' : '/';
if (pathsep == path[path.length - 1]) path += 'index.html';

mojodna commented Dec 7, 2011

+1 on @andihit's fix.

mojodna commented Dec 7, 2011


if (normalize('/') == path[path.length - 1]) path += 'index.html';

hdf commented Dec 16, 2011

Yes, this bug has been bothering me for months now.
+1 on @mojodna -s fix.

tj closed this in b74a338 Dec 16, 2011


tj commented Dec 16, 2011

sorry for the delay i've been sick, i'll push a new release

keichii commented Feb 9, 2012

this is wrong... please adjust
if (normalize('/') == path[path.length - 1]) path += 'index.html';


if (normalize('/') == normalize(path[path.length - 1])) path += 'index.html';

broked all the frameworks who used this:


it fixed this bug on windows.

oluwie commented Apr 19, 2012

This fix works on all browsers for me except for Chrome.

Any ideas????

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