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.

Target Server with serverMiddleware which adds content

See original GitHub issue

I have an api as a nuxt serverMiddleware which creates entries to the /content folder on post requests. I expected that $content fetches all entries, also the newly created ones. In dev it works, build & start does not work: it only shows the entries which are available at build time.

Is this intended? Is there a way to make it working?

nuxt.config.js

target: 'server',
ssr: true,

pages/index.vue

async asyncData ({ $content }) {
    const tests = await $content('tests').fetch()
    return {
      tests
    }
  }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
fabianwohlfartcommented, May 13, 2021

finally solved it. digged through the source code and found that there is watch property. watch property is not named in the docs. why? is there a downside to it? will open an enhancement for this.

  content: {
    watch: true
  },
0reactions
fabianwohlfartcommented, May 25, 2021

it works fine with custom server middleware for authentification. thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

The serverMiddleware Property - Nuxt
The serverMiddleware property ... Define server-side middleware. ... Nuxt internally creates a connect instance that you can add your own custom middleware to....
Read more >
Nuxt server middleware with generate - Stack Overflow
Server middleware basically allows you to run your own code on the server nuxt spins up for you in target: 'server' mode.
Read more >
Make serverMiddleware available when generating static pages
Some server side data APIs are provided as serverMiddleware. ... Downloaded the nuxt version 2.14 and set up the target property.
Read more >
How to Configure SSG and SSR on Nuxt.js - Mad Devs
There, you add metadata, connect plugins, configure the server, ... Then, in nuxt.config.js file, add a new key serverMiddleware.
Read more >
Nuxt.js for Busy Developers - CODE Magazine
The app content, composed of JS and CSS files, loads one time only. ... Think of a server-middleware as a Node.js middleware you...
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