Initial attempt at node.js automatic redirection I'm working on a Node.js HTTP server on my iPhone:

var fs = require("fs");
var http = require('http');
const port = 8080; 
var readFile = function(name, response) {
    var read = function(err, dat) {
        var rv = null;
        var nope = "./redirect.html";
        if (err) {
            if (name == nope)
                rv = "INTERNET!";
            else {
                rv = readFile(nope, response);
                return;
            }
        }
        else rv = dat;
        response.end(rv);
    }
    fs.readFile(name, "utf-8", read);
}
var client = function(request, response) {
    path = "." + request.url;
    file = readFile(path, response);
}
var server = http.createServer(client);
server.listen(port);


redirect.html:

&lt;script language = "javascript"&gt;
window.location = "/index.html";
&lt;/script&gt;
Bad request.
if (err) {
        if (name == nope)
            rv = "INTERNET!";
        else {
            rv = readFile(nope, response);
            return;
        }
    }
    else rv = dat;



Omitting {} can easily go sideways especially if you mix it like in the example above. I suggest to always use them.

Even if it's just

else { rv = dat; }


they greatly helps to see where the if/else ends.


var nope = "./redirect.html";



Since you doesn't seem to change it anwhere, I'd make it a constant too.