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.

Question: defineNuxtPlugin access old context.req

See original GitHub issue

Environment


  • Operating System: Darwin
  • Node Version: v16.15.0
  • Nuxt Version: 3.0.0-rc.3
  • Package Manager: pnpm@7.1.3
  • Builder: vite
  • User Config: srcDir, css, build, vite
  • Runtime Modules: -
  • Build Modules: -

Reproduction

import { defineNuxtPlugin } from "#app"

export default defineNuxtPlugin((nuxtApp) => {
  console.log(nuxtApp) // doesn't have context or context.req
})

Describe the bug

Creating a plugin on nuxt 2 i only use

export default (context) => {
   console.log(context.req) //here i can access context.req
}

How can I get context.req if i also need to use defineNuxtPlugin((nuxtApp)) ?

Thank you for the help

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
stephenjason89commented, Jun 9, 2022

Thank you @danielroe, you are a lifesaver.

0reactions
stephenjason89commented, Jul 10, 2022

Oh i’m getting your point now, I’m so sorry, i have overlooked this issue. 😀 As always, you are a lifesaver. Thank you so much

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt.js3 plugin's context becomes undefined - Stack Overflow
Please import useRuntimeConfig from '#app' . So in your example change the first line: import { defineNuxtPlugin } from '#app'. Into:
Read more >
The context - Nuxt
The context provides additional objects/params from Nuxt to Vue components and is available in special nuxt lifecycle areas.
Read more >
Nuxt Context: where is it in Nuxt 3 - Krutie Patel
In Nuxt 2, res and req objects are available through the context object only on server-side. ... In Nuxt 3, we have a...
Read more >
Creating Server-side Rendered Vue.js Apps Using Nuxt.js
On the Context, we can access the req object, which stores all the headers and other information from the client request. (This will...
Read more >
Working with context, helpers, and advanced properties in ...
The Nuxt context is an additional collection of data about the current ... when they do not meet the requirements to access certain...
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