Created
December 29, 2011 21:19
-
-
Save tbeseda/1536247 to your computer and use it in GitHub Desktop.
Basic HTTP Auth with Express for Node.js
This file contains hidden or 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
express = require 'express' | |
app = express.createServer() | |
auth = express.basicAuth 'yourmom', 'p4ssw0rd' | |
app.get '/', auth, (req, res) -> | |
res.send your_super_secret_stuff | |
app.listen 3000, -> | |
console.log "Listening on #{port}" |
This file contains hidden or 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
express = require 'express' | |
app = express.createServer() | |
auth = express.basicAuth 'yourmom', 'p4ssw0rd' | |
# Specify auth middleware and fire off next | |
app.get '/', auth, (req, res, next) -> next() | |
# Set up static middleware *after* your routes | |
app.use express.static "#{__dirname}/public" | |
app.listen 3000, -> | |
console.log "Listening on #{port}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment