vuetifyjs / vuetify

🐉 Vue Component Framework
https://vuetifyjs.com
MIT License
39.7k stars 6.95k forks source link

Vue Plugins are not available on server after reload #111

Closed smyth64 closed 7 years ago

smyth64 commented 7 years ago

Hey guys.

I really like your package but it seems that the plugins which I register with Vue.use('...') are not availabe at server side.

Reproduction:

git clone https://github.com/smith64fx/vuetify-ssr-problem
cd vuetify-ssr-problem
npm i
npm run dev

Side Note

The only 2 things I changed are these 2 files:

app.js

...
import axios from 'axios'
import VueAxios from 'vue-axios'

Vue.use(VueAxios, axios)
...

GetStartedView.vue

<script>
import Vue from 'vue'

export default {
  created () {
    console.log(this)
    console.log("================")
    console.log(this.axios)
  }
}
</script>

Here comes he bug

Now open the page at localhost:8080

In the browser you will see: image

In the server console it's really strange. The first time I open the pageI the vue-axios plugin is loaded in the server side.

================
{ [Function: bound wrap]
  request: [Function: wrap],
  delete: [Function: wrap],
  get: [Function: wrap],
  head: [Function: wrap],
  post: [Function: wrap],
  put: [Function: wrap],
  patch: [Function: wrap],
...........................
.............
...

But if I reload the page now, Vue.axios is suddenly undefined!

================
undefined

Whereas on the frontend side the Vue.axios plugin is always available.

Can you please help us? We have tried everything but we don't have any idea :/ We really want to use your SSR-Seed for our projects!

Thank you!

smyth64 commented 7 years ago

We found the error: It is because of the package.json.

You placed the vue-router into the devDependencies. After putting it into the normal dependencies everything works.

We are going to fix this and make a pull request.

johnleider commented 7 years ago

Awesome, thank you.

johnleider commented 7 years ago

No response or PR received from this.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please direct any non-bug questions to our Discord