Conflict of onBeforeRender between _default.page.server.js and .page.server.js
See original GitHub issueAs I refer to the example of vuex provided, everything works well. But whenever I add a custom .page.server.js
, an error of Argument 'str' should be a string but we got 'typeof str === "undefined"'
will occur, and the whole page will become empty
Seems like the onBeforeRender in _default.page.server.js and .page.server.js conflicts with each other, as everything will back to normal again when I delete/clear the custom .page.server.js
file
To reproduce:
git clone git@github.com:IT-iddiot/vite-plugin-ssr-bug-reproduce.git
cd vite-plugin-ssr-bug-reproduce
npm install
npm run start
If you visit localhost:3000 now, everything should work normally.
Now you go to pages/index.page.server.js, and uncomment all the code inside. If you check the browser now, the page will be empty.
I am curious is there any way to use Vuex and customer .page.server.js at the same time. Any help is appreciated, Thank you
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
I’m glad you found something to your pleasing.
If you believe there is a bug in
vite-plugin-ssr
, feel free to push.I’m actually working on it at the moment.
I have tried, also cannot. Now I manage my SEO metadata through Vuex, which works quite well for me now ( inspired by the solution here https://github.com/brillout/vite-plugin-ssr/issues/34#issuecomment-821974773 )
Here is a simple example:
_default.page.server.js
, use the title and description from your Vuex storeIt works for me now, although I am not sure whether this is a good way to do it. I have tried @vueuse/head and vue-meta@next before, but none of them works for me.
But I still looking forward to the ability to use onBeforeRender on default server js and custom page server js at the same time, cause now I stuck with the custom tracking code per page haha.
Anyway, thank you for this awesome tool 👍🏼