Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sabrydawood/virus-back
tracks the previous page a user visited in sessions, allowing for reliable back one page redirects.
https://github.com/sabrydawood/virus-back
Last synced: about 1 month ago
JSON representation
tracks the previous page a user visited in sessions, allowing for reliable back one page redirects.
- Host: GitHub
- URL: https://github.com/sabrydawood/virus-back
- Owner: sabrydawood
- Created: 2022-11-19T01:15:42.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-19T14:12:03.000Z (about 2 years ago)
- Last Synced: 2024-10-17T06:52:57.590Z (3 months ago)
- Language: JavaScript
- Size: 2.82 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## virus-back
The http referer header is unreliable, virus-back uses sessions to track the two previous paths a client has visited. Also provides a convienence method `res.back()` to safely redirect to the previous path or fallback as to prevent a redirect loop.### Usage
```jsvar back = require('virus-back');
app.use(session({
secret: 'Session Secret'
}));
app.use(back());app.get('/test', function(req, res) {
if (!req.isAuthenticated()) {
return res.back();
}
});
```### API
```js
var back = require('virus-back');
```
This middleware depends upon a session middleware or `req.session`, and will populate `req.prevPath` and `req.prevPrevPath`.#### back(options)
* options {Object}
* options.default {String} The fallback path to populate req.prevPath and req.prevPrevPath, defaults to '/'