Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I am building a single page web application with Express.js on the back-end. However, I want to keep the login/register/homepage to the application (before you login) separate from the single page application (after you login), but on the same root URL (/).

My question is how would you recommend designing this? Currently I have server-side templates rendered and served by routes in Express.js for /, /login, and /register (because I don't want the pre-app part of the web site to be appy). Then, when the user logs in, I serve a different server-side template to the / GET route:

app.get('/', function (req, res) {
  if (!req.isAuthenticated()) {
    return res.render('index');
  }

  res.render('app')
})

This file then serves the rest of the application by providing a link to the client-side JavaScript (Backbone.js/AngularJS, etc.)

I am looking to receive criticism on this design. Is this the best way for me to achieve my desired application design, using Express.js and a mix of client/server-side templates?

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.