Getting Quasar’s SSR cookie plugin working with other libraries and services.
Table Of Contents
1 Introduction
2 The Problem...
For further actions, you may consider blocking this person and/or reporting abuse
I changed the
axios
boot file like below by addingVue.mixin
instead ofVue.prototype
. But now when I try to accessthis.$axios.post()
in.vue
component its throwingTypeError: Cannot read property 'post' of undefined
. So the global mixin is not passing into components. I simply copied the mixin logic from here.Any insights on what could be the issue here?
this would be:
Thank you.
Great article! Can you please show your final implementation on Github repo?
really sorry, i missed your comment.:
gitlab.com/TobyMosque/quasar-couch...
I think this link is not for this article as this code is missing there. Could you please share the correct link if possible?
ops, i didn't created a repo to this article, mostly because this is a simplified version of what i do.
Normally, I didn't access the cookies directly, i use
vuex-persistedstate
as a middleware.but u can access the Cookies directly, there is nothing wrong with this approach
github.com/TobyMosque/qpanc/blob/m...
And here the axios part:
github.com/TobyMosque/qpanc/blob/m...
I'll try to create a repo to this article at the weekend.
Ok. Thank you for the support
This guide has been invaluable, thank you. Just one thing I'm trying to puzzle out - what is the purpose of the
beforeCreate()
code here? Is there a reason to prefer this over injecting the Axios instance in the Vue prototype?Vue.prototype
is shared between allVue
instances, what will result in a singleaxios
instance to allVue
instances (a singleton).But in that particular case, a singleton can mess with our autentication logic, since that is being handled into the
axios
interceptor and this reads the token from the Cookies plugin, what isn't a singleton, what can lead to a data leak.Thank you man!
Thank you for the excellent article! It would be nice to have this added to the Quasar documentation (if it is not there already), as it is rather square one if you want to implement SSR. I'd have one small remark, under 5 Navigation guards, in ./src/router/index.js, I had to switch context.router.beforeEnter to context.router.beforeEach. As far as I know, there is no global guard beforeEnter now in Vue Router, I'm not sure for older versions.
probably a small typo, thx for report.
Also a great Article and perfect understandable written.
Thank you for sharing your know how.
how can I get app context for call my other service?
I didn't understood u question