forked from mariusGundersen/ajax-login
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
32 lines (26 loc) · 916 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Run via "node server.js"
// For https uncomment some lines below and run "sudo /opt/bin/node server.js"
// FYI: Firefox only save passwords when page is served over https
var express = require('express');
var bodyParser = require('body-parser');
// Uncomment for https:
//var https = require('https');
var http = require('http');
var fs = require('fs');
// Uncomment for https:
//var options = {
// key: fs.readFileSync('/etc/nginx/ssl/my.key.pem'),
// cert: fs.readFileSync('/etc/nginx/ssl/my.cert.pem')
//};
var app = express();
app.use(bodyParser.urlencoded());
app.post('/login', function(req, res){
res.redirect(req.body.redirectTo);
// or for the XMLHttpRequest test (uncomment the redirect in the line above):
//res.send('Hello World!');
});
app.use(express.static(__dirname));
app.listen(8080);
// Uncomment for https:
// https.createServer(options, app).listen(443);
console.log("started");