https://github.com/ladjs/express-redirect-loop
Prevent redirect loops with sessions since HTTP referrer header is unreliable
https://github.com/ladjs/express-redirect-loop
301 302 endless express fix loop recursive redirect redirection
Last synced: 2 months ago
JSON representation
Prevent redirect loops with sessions since HTTP referrer header is unreliable
- Host: GitHub
- URL: https://github.com/ladjs/express-redirect-loop
- Owner: ladjs
- License: mit
- Created: 2018-01-30T09:28:01.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-08T08:03:32.000Z (about 3 years ago)
- Last Synced: 2024-11-24T20:30:04.628Z (6 months ago)
- Topics: 301, 302, endless, express, fix, loop, recursive, redirect, redirection
- Language: JavaScript
- Homepage: https://lad.js.org
- Size: 493 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-redirect-loop
[](https://travis-ci.org/niftylettuce/express-redirect-loop)
[](https://codecov.io/gh/niftylettuce/express-redirect-loop)
[](https://github.com/sindresorhus/xo)
[](https://github.com/prettier/prettier)
[](https://lass.js.org)
[](LICENSE)> Prevent redirect loops with sessions since HTTP referrer header is unreliable
## Table of Contents
* [Install](#install)
* [Usage](#usage)
* [Contributors](#contributors)
* [License](#license)## Install
[npm][]:
```sh
npm install express-redirect-loop
```[yarn][]:
```sh
yarn add express-redirect-loop
```## Usage
```js
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** | |## License
[MIT](LICENSE) © [Nick Baugh](http://niftylettuce.com/)
##
[npm]: https://www.npmjs.com/
[yarn]: https://yarnpkg.com/