Authorized routes
- Vorherrschende Sprache
- TypeScript
- Sterne
- 38
- Forks
- 1
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
### ⚠️ The example in this OP is outdated. See https://github.com/alloc/saus/issues/56#issuecomment-1143963756
---
Add an `authorizeRoutes` route hook, used like so:
```ts
// ./src/node/routes.ts
import { authorizeRoutes, Redirect } from 'saus'
// The route pattern is optional. If none is provided, all routes are authenticated.
authorizeRoutes('*', async (headers, url) => {
if (verify(headers)) {
return true
}
// Redirect the request, or return false to act like this route doesn't exist.
return new Redirect('/login')
})
const verify = (headers) => {
// TODO: verify a Cookie header or JWT token, etc
}
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.