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.

db.json is loaded client-side for static site that is not using $content within the client code

See original GitHub issue

Version

@nuxt/content: 1.12.0 nuxt: 2.14.12

Reproduction Link

No minimal repro (yet)

Steps to reproduce

We recently rebuilt our documentation at Cypress.io to use nuxt and nuxt-content. We are building the site using nuxt generate. We have a page that is requesting the db.json file despite the site being generated with nuxt generate and none of the client code is using $content (this should only be called when building the static site). From what I’ve read, the db.json should not be loaded unless $content is used client-side.

  1. Go to https://docs.cypress.io

  2. Click on “Plugins” in the top header

  3. The page will not redirect immediately because the db.json file is being fetched.

What is Expected?

The /plugins page does not fetch db.json since the $content API is not being used client-side in this statically generated site.

What is actually happening?

The /plugins page requests the db.json on load, causing a noticeable delay before the user can land on /plugins.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
matthamilcommented, Mar 23, 2021

Thanks a bunch @danielroe! This helped.

0reactions
danielroecommented, Mar 23, 2021

@matthamil A pleasure 😊

Read more comments on GitHub >

github_iconTop Results From Across the Web

Client-side storage - Learn web development | MDN
Most major modern websites are dynamic — they store data on the server using some kind of database (server-side storage), then run server-side ......
Read more >
Fetch Data from a JSON File in a React App | Pluralsight
This guide will demonstrate how to correctly fetch data from a JSON file in your React app and consume it on the frontend....
Read more >
Client-side data fetching - Next.js
Learn about client-side data fetching, and how to use SWR, a data fetching React hook library that handles caching, revalidation, focus tracking, ...
Read more >
How to use NextAuth.js for client-side authentication in Next.js
Learn how to use NextAuth.js for client-side authentication in Next.js. Users can login with a GitHub, Google, or Facebook account.
Read more >
How to read an external local JSON file in JavaScript?
For reading the external Local JSON file (data.json) using javascript, first create your data.json file: data = '[{"name" : "Ashwin", "age" : "20"},{"name" ......
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