Skip to content

Instantly share code, notes, and snippets.

@nicovalencia
Created August 16, 2013 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicovalencia/6253109 to your computer and use it in GitHub Desktop.
Save nicovalencia/6253109 to your computer and use it in GitHub Desktop.
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