WriteOn / WriteOnApp

On a mission to create the world's finest writing experience.
https://writeon.io
Apache License 2.0
1 stars 0 forks source link

Infinite Redirect Loop on www only #58

Closed thinq4yourself closed 9 years ago

thinq4yourself commented 9 years ago

For those that use www with writeon.io, of which there ARE FEW, I put a server redirect from www to root domain. However, I messed up. Below is the new code for 1.10.4:

/* 
 * FORCE HTTPS
 */
// Used to force SSL - required for security =============================
app.use('*', function(req, res, next) {
    if(req.headers['x-forwarded-proto'] != 'https') {
        return res.redirect('https://' + req.hostname + req.originalUrl);
    } 
    else if (req.headers.host == 'www.writeon.io') {
        return res.redirect('https://writeon.io' + req.originalUrl);
    }
    /\.(eot|ttf|woff|svg|png)$/.test(req.path) && res.header('Access-Control-Allow-Origin', '*');
    return next();
});

However, for those FEW who did use www, redirect would not allows them to get their stories out of www and into root, so UGH I have to disable it. Effin frustrating.