Skip to content

Commit

Permalink
Add example on how to enable jwt for specific path
Browse files Browse the repository at this point in the history
Add example on how to enable jwt for specific path, as compared to _disabling_ for a specific path which was the only example shown before.
  • Loading branch information
vidstige authored and jfromaniello committed Apr 20, 2022
1 parent edeb965 commit 2805113
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ jwt({
});
```

Optionally you can make some paths unprotected as follows:
To only protect specific paths (e.g. beginning with `/api`), use [express router](https://expressjs.com/en/4x/api.html#app.use) like so:

```javascript
app.use('/api', jwt({ secret: 'shhhhhhared-secret', algorithms: ['HS256']}));
```

Or, the other way around, if you want to to make some paths unprotected as follows:

```javascript
app.use(
Expand Down

0 comments on commit 2805113

Please sign in to comment.