Vue-meta: Updating to v2.x: meta.inject() in SSR HTML is undefined

Created on 11 Jun 2019  路  8Comments  路  Source: nuxt/vue-meta

I've read the "Migration Guide" parts of the changelogs, but couldn't find anything that points me in the right direction:

When I upgrade to version 2.x, the server side rendering of my app fails.
1.) I get the warning "This vue app/component has no vue-meta configuration"
2.) I get the Error: "TypeError: Cannot read property 'title' of undefined" (this comes from my HTML file where I use {{{meta.inject().title.text()}}} - meta.inject() seems to be undefined.

This is a part of my entry_server.js:

export default context => {
    return new Promise((resolve, reject) => {
        createApp().then(data => {
            context.meta = data.app.$meta();
...

Is there anything else that changed and needs to be modified?
Unfortunately it's not easy to prepare a minimal app to isolate the error, but perhaps others have had this problem when upgrading their SSR app, too and can give me a hint.

Thank you!

bug

Most helpful comment

+1. upgrade to 2.0.2 from 1.5.6. My code is not change, but get the error:

This vue app/component has no vue-meta configuration

when do render by the vue-server-render, it get:

TypeError: Cannot read property 'meta' of undefined

All 8 comments

Thanks for the report, could you maybe create a reproduction using the ssr example? https://github.com/nuxt/vue-meta/blob/master/examples/ssr

+1. upgrade to 2.0.2 from 1.5.6. My code is not change, but get the error:

This vue app/component has no vue-meta configuration

when do render by the vue-server-render, it get:

TypeError: Cannot read property 'meta' of undefined

@pimlie I created a basic public repository of my stripped down application:
https://github.com/diff-dennis/vue-meta-test

Please let me know if this helps somehow. It worked in versions 1.x and I could not find anything in the changelog / migration notes that tells me what to change.

Thanks for the quick repro. It seems to be caused by this check: https://github.com/nuxt/vue-meta/blob/master/src/server/%24meta.js#L17

This check was added to provide an early exit if no metaInfo was defined on the app, but I missed your use-case where you call this method before the app has been initiated. Will revert this change for the server plugin, I think it should still be fine client-side.

@pimlie Thank you very much!

I still need to add a proper test-case for this use-case, but in the mean time please check v2.0.3 which has the check removed.

@pimlie This seems to work, thanks again!

@cuiyongjian If it doesnt work for you, let me know and I will reopen the issue. Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iMomen picture iMomen  路  5Comments

wilco-superbalist picture wilco-superbalist  路  4Comments

dysol picture dysol  路  6Comments

cr-lgl picture cr-lgl  路  8Comments

vishr picture vishr  路  5Comments