Created
August 16, 2013 20:06
-
-
Save nicovalencia/6253109 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _writeHead = res.writeHead; // Store the original function | |
res.writeHead = function(statusCode, headers) { | |
res.writeHead = _writeHead; // Put the original back | |
if (statusCode === 401) { | |
// Change a 401 statusCode to a 403 in order to prevent browser's BASIC AUTH dialog from appearing. | |
// This allows the Backbone app's login page to handle the credentials. | |
_writeHead.call(res, 403, headers); | |
} else { | |
res.writeHead(statusCode, headers); // Call the original | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment