Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
Nuxt.js can't set cookie, "undefined (reading 'set')" (cookie-universal-nuxt)

When trying to set a cookie with cookie-universal-nuxt in my router middleware I get the error:

TypeError: Cannot read properties of undefined (reading 'set')

What is causing this?

nuxt.config.js

modules: [
    'cookie-universal-nuxt',
],

router.js (router middleware)

export default async ({ app }) => {

    app.$cookies.set('cookie-name', 'cookie-value', {
        path: '/',
        maxAge: 60 * 60 * 24 * 7
    });
}

I tried logging in different places:

When I run console.log(app.$cookies) in the router it returns undefined.

When I run it in a component (so: console.log(this.app.$cookies)) it returns Cannot read properties of undefined (reading 'app'). I am using the composition-api so I also tried console.log(context.root.$cookies) but this also returns undefined.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!