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:<script language = javascript>window.location = /index.html;</script>Bad request.
Initial attempt at node.js automatic redirection
javascript;node.js;http;server
    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 justelse { 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.