question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'req' of undefined

See original GitHub issue

Version

nuxt-i18n: 6.11.1 nuxt: 2.11.0

Nuxt configuration

[mode]

  • [ x ] universal

Nuxt-i18n configuration

i18n: {
    strategy: 'prefix_except_default',
    locales: [
      { code: 'en', file: 'en.json' },
      { code: 'de', file: 'de.json' }
    ],
    defaultLocale: 'en',
    vueI18n: {
      fallbackLocale: 'en'
    },
    lazy: true,
    langDir: 'i18n/',
    detectBrowserLanguage: {
      useCookie: true,
      cookieKey: 'i18n_redirected',
      fallbackLocale: 'en'
    }
  }

Steps to reproduce

Try to invoke localeLink function on $root on SSR. Like

const { $root } = this;
$root.localePath(...)

What is Expected?

Path is generated properly.

What is actually happening?

Getting TypeError.

It is known issue been discussed in ticket https://github.com/nuxt-community/nuxt-i18n/pull/596 And the PR was merged, but now looks like it has been reverted… In a nutshell, on SSR $root instance $ssrContext should be replaced by ssrContext.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12

github_iconTop GitHub Comments

3reactions
lukeromanowiczcommented, Nov 25, 2020

If you are using vue-composition-api plugin it’s because root’s $ssrContext is undefined. It’s moved to the context.ssrContext. I am not sure if the same case happens to non CAPI scenarios

0reactions
dschreijcommented, Mar 4, 2021

and there is no next version.

Apologies, I think I accidentally confused this with vue-i18n itself, in which they have added support for capi if I’m not mistaken.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Express.js Cannot read property 'req' of undefined
My Express. js app has been throwing Cannot read property 'req' of undefined . In essence, it listens for a GET request, grab...
Read more >
Cannot read property req body undefined in express - YouTube
codercrab #express #body-parserCannot read property req body undefined in express ||Express req body is undefined for post requests.
Read more >
TypeError: Cannot read property 'req' of undefined · Issue #711
Error that I described is happening only client-side, so I am guessing that it caused by destroyed component. All reactions.
Read more >
TypeError: Cannot read property 'send' of undefined : NodeJs
The error is occurring because req.body is undefined . You need to configure Express to parse JSON request bodies. You can do this...
Read more >
getting "TypeError: Cannot read property 'quote' of undefined ...
getting "TypeError: Cannot read property 'quote' of undefined" The terminal shows the error at app.js 22:23. const express = require('express'); ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found