{"id":18926774,"url":"https://github.com/ladjs/koa-redirect-loop","last_synced_at":"2025-04-15T13:33:20.291Z","repository":{"id":42373030,"uuid":"229741224","full_name":"ladjs/koa-redirect-loop","owner":"ladjs","description":"Prevent redirect loops with sessions since HTTP referrer header is unreliable and ensures sessions are saved upon redirect","archived":false,"fork":false,"pushed_at":"2022-11-21T19:33:14.000Z","size":1073,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-04T23:21:18.908Z","etag":null,"topics":["301","302","endless","fix","http","koa","loop","prevent","redirect","redirection","referer","referrer"],"latest_commit_sha":null,"homepage":"https://lad.js.org","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ladjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-23T11:43:13.000Z","updated_at":"2022-11-21T19:35:03.000Z","dependencies_parsed_at":"2023-01-21T11:10:27.922Z","dependency_job_id":null,"html_url":"https://github.com/ladjs/koa-redirect-loop","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fkoa-redirect-loop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fkoa-redirect-loop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fkoa-redirect-loop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fkoa-redirect-loop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ladjs","download_url":"https://codeload.github.com/ladjs/koa-redirect-loop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223672916,"owners_count":17183618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["301","302","endless","fix","http","koa","loop","prevent","redirect","redirection","referer","referrer"],"created_at":"2024-11-08T11:17:08.553Z","updated_at":"2024-11-08T11:17:09.241Z","avatar_url":"https://github.com/ladjs.png","language":"JavaScript","readme":"# koa-redirect-loop\n\n[![build status](https://github.com/ladjs/koa-redirect-loop/actions/workflows/ci.yml/badge.svg)](https://github.com/ladjs/koa-redirect-loop/actions/workflows/ci.yml)\n[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://lass.js.org)\n[![license](https://img.shields.io/github/license/ladjs/koa-redirect-loop.svg)](LICENSE)\n[![npm downloads](https://img.shields.io/npm/dt/koa-redirect-loop.svg)](https://npm.im/koa-redirect-loop)\n\n\u003e Prevent redirect loops with sessions since HTTP referrer header is unreliable and ensures sessions are saved upon redirect\n\n\u003e Note that this package only supports `koa-generic-session`, since other packages do not expose a save method used in `res.end` override.\n\n\n## Table of Contents\n\n* [Install](#install)\n* [Usage](#usage)\n* [Options](#options)\n* [Contributors](#contributors)\n* [License](#license)\n\n\n## Install\n\n[npm][]:\n\n```sh\nnpm install koa-redirect-loop\n```\n\n\n## Usage\n\n```js\nconst Koa = require('koa');\nconst session = require('koa-generic-session');\nconst RedirectLoop = require('koa-redirect-loop');\n\nconst redirectLoop = new RedirectLoop({\n  defaultPath: '/',\n  maxRedirects: 5,\n  logger: console\n});\n\nconst app = new Koa();\napp.keys = [ 'secret' ];\n\napp.use(session());\napp.use(redirectLoop.middleware);\n```\n\n\n## Options\n\n* `getDefaultPath` (Function) - function which accepts `ctx` argument and returns a path to fallback to, defaults to either `/${ctx.request.locale}` (e.g. if using `@ladjs/i18n`) or `/`\n* `defaultPath` (String) - path to fallback to, defaults to `'/'`\n* `maxRedirects` (Number) - maximum number of redirects to allow, defaults to `5`\n* `console` (Object) - a logger instance, defaults to `console`\n\n\n## Contributors\n\n| Name           | Website                    |\n| -------------- | -------------------------- |\n| **Nick Baugh** | \u003chttp://niftylettuce.com/\u003e |\n\n\n## License\n\n[MIT](LICENSE) © [Nick Baugh](http://niftylettuce.com/)\n\n\n##\n\n[npm]: https://www.npmjs.com/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladjs%2Fkoa-redirect-loop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fladjs%2Fkoa-redirect-loop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladjs%2Fkoa-redirect-loop/lists"}