Skip to content

Prevent redirect loops with sessions since HTTP referrer header is unreliable

License

Notifications You must be signed in to change notification settings

ladjs/express-redirect-loop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Aug 22, 2020
b4fd896 · Aug 22, 2020

History

19 Commits
Aug 22, 2020
Jan 30, 2018
Jan 30, 2018
Jan 30, 2018
Oct 6, 2018
Jan 30, 2018
Aug 22, 2020
Jan 30, 2018
Feb 1, 2018
Aug 22, 2020
Aug 22, 2020
Aug 22, 2020

Repository files navigation

express-redirect-loop

build status code coverage code style styled with prettier made with lass license

Prevent redirect loops with sessions since HTTP referrer header is unreliable

Table of Contents

Install

npm:

npm install express-redirect-loop

yarn:

yarn add express-redirect-loop

Usage

const express = require('express');
const session = require('express-session');
const redirectLoop = require('express-redirect-loop');

const app = express();

app.use(
  session({
    secret: 'test',
    resave: false,
    saveUninitialized: true
  })
);

app.use(redirectLoop({
  defaultPath: '/',
  maxRedirects: 5
}));

app.get('/', (req, res) => res.sendStatus(200));
app.get('/bar', (req, res) => res.redirect('/foo'));
app.get('/foo', (req, res) => res.redirect('/foo'));
app.get('/baz', (req, res) => res.redirect('/bar'));

app.listen(3000);

Contributors

Name Website
Nick Baugh http://niftylettuce.com/

License

MIT © Nick Baugh