UPDATE: Using a different path for my successRedirect I have managed to get a 200 response to my GET request (see code below). This is ONLY true the FIRST TIME I hit the route, though. Even so, the browser does not change the page rendered. i.e. after I successfully register a dummy user, there is no actual redirect.
After some more research about code 304 and some playing it seems like a caching issue, but that's as far as I've gotten thus far.
GET /test
app.get('/test', function(req, res) {
res.render('video-view.html');
});
// process the signup form
app.post('/signup', passport.authenticate('local-signup', {
successRedirect : '/test', // redirect to the secure profile section
failureRedirect : '/sign-up', // redirect back to the signup page if there is an error
failureFlash : true // allow flash messages
}));
I'm having a lot of trouble getting my router to properly redirect after a successful local signup. My /config/passport.js file properly adds a row to the database and appears to serialize the session. It returns the user to my router, which attempts to redirect the browser. Looking at my console requests, I see this unsuccessful request: GET /home 304.
I've been working at this for quite a while now and haven't been able to find a solution or fix the problem. Part of my issue is that I'm not using a templating engine - just serving html scripted with angular.js. Maybe I haven't configured this properly, but all other routing and functionality is working well. Any thoughts?
Here is my router code:
var express = require('express');
module.exports = function(app, passport) {
app.get('/signup', function(req, res) {
// render the page and pass in any flash data if it exists
res.render('sign-up.html');
});
app.get('/home', function(req, res) {
res.render('video-view.html');
});
app.post('/signup', passport.authenticate('local-signup', {
successRedirect : '/home', // redirect to the secure profile section
failureRedirect : '/signup', // redirect back to the signup page if there is an error
failureFlash : true // allow flash messages
}));
};
My server is set up like this:
var express = require('express');
var app = express();
var port = process.env.PORT || 8080;
var passport = require('passport');
var flash = require('connect-flash');
require('./config/passport')(passport); // pass passport for configuration
app.configure(function() {
app.use(express.logger('dev')); // log every request to the console
app.use(express.cookieParser()); // read cookies (needed for auth)
app.use(express.bodyParser()); // get information from html forms
app.engine('html', require('ejs').renderFile);
app.use('/', express.static(__dirname + '/views'));
app.use(express.session({ secret: 'vidyapathaisalwaysrunning' } )); // session secret
app.use(passport.initialize());
app.use(passport.session()); // persistent login sessions
app.use(flash()); // use connect-flash for flash messages stored in session
});
require('./app/routes.js')(app, passport); // load our routes and pass in our app and fully configured passport
app.listen(port);