You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/common-patterns.md
+285Lines changed: 285 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -507,3 +507,288 @@ export default new Vuex.Store({
507
507
## Enable Debug Logging
508
508
509
509
If items aren't not getting added to the store properly, try setting the `debug` option on the `makeServicePlugin` to `true`. It enables some additional logging that may be useful for troubleshooting.
510
+
511
+
## Full nuxt example
512
+
513
+
In this example we will create a nuxt configuration with all the features discribed in the [Nuxt Section](./nuxt.md).
514
+
515
+
Our application is hosted in 2 different endpoints, one for the feathers api and another with our nuxt SSR, and we will also implement a permission system that will prevent users without an `admin` permission to get into some pages. For that you will need to [customize your payload](https://docs.feathersjs.com/cookbook/authentication/stateless.html#customizing-the-payload) in your feathers api.
The `admin` middleware will redirect any user that is not loged in or do not have the `admin` permission to a `not-permited` page.
557
+
558
+
```js
559
+
// ~/middleware/admin.js
560
+
exportdefaultfunction ({ store, redirect }) {
561
+
const { auth } =store.state
562
+
constpermissions=auth.payload.permissions
563
+
if (
564
+
!auth.payload||
565
+
!permissions.includes('admin')
566
+
) {
567
+
returnredirect('/not-permited')
568
+
}
569
+
}
570
+
```
571
+
Add the `admin` middleware to the administrative pages
572
+
573
+
```js
574
+
// ~/pages/**
575
+
exportdefault {
576
+
577
+
...
578
+
579
+
middleware: ['admin']
580
+
581
+
...
582
+
583
+
}
584
+
```
585
+
586
+
In the feathers client configuration we will use a different transport for the nuxt-server > api comunication and the nuxt-client > api. When we are making request on the server we do not need the socket io realtime messaging system so we can use an rest configuration for better performance.
0 commit comments