vercel-builder icon indicating copy to clipboard operation
vercel-builder copied to clipboard

@nuxtjs/content

Open eigenmannmartin opened this issue 6 years ago • 10 comments

When I use https://content.nuxtjs.org/ in my build. I get a 404 for the fetch. When I run npm run build and npm run start locally it works fine.

Any Idea why it might not work?

eigenmannmartin avatar Aug 15 '20 19:08 eigenmannmartin

@eigenmannmartin Do you use 2.14? Before that you had to use the generate function to tell nuxt which routes to generate. Take a look at their documentation.

appinteractive avatar Aug 19 '20 10:08 appinteractive

@appinteractive I am using "@nuxt/content": "^1.3.2", and "nuxt": "^2.13.0",

I will update and check again :+1: Thank you very much!

eigenmannmartin avatar Aug 20 '20 12:08 eigenmannmartin

Same error here with the latest version. It seems, that content folder is not added to the server files. I have solved it by adding content folder to now.json config:

{
    "version": 2,
    "builds": [
      {
        "src": "nuxt.config.js",
        "use": "@nuxtjs/now-builder",
        "config": {
            "serverFiles": ["content/**"]
        }
      }
    ]
  }

This solves the 502 error which couldn't fetch any files and /_content/articles is accessible and returns all results.

Regardless, after accessing the page with @nuxtjs/content content, I'm getting Error: Uncaught (in promise) TypeError: Cannot read property 'chain' of null

Check logs for SSR here: https://vercel.com/dawidstefaniak/content-test/14k0i7avq/functions And link: https://content-test-14k0i7avq.vercel.app/articles

Logs for SPA (for reference that it does work): https://vercel.com/dawidstefaniak/content-test/px349i0a8

Any help with that? I think it may be some error with @nuxtjs/content itself.

dawidstefaniak avatar Aug 22 '20 14:08 dawidstefaniak

In a serverless environment you can't access your own API endpoints within the serverless function, which is what the content module relies on. (That is, for example, you can't try an HTTP get request to an endpoint served by the function - because it won't be accessible via http://localhost: 3000.) Short of it being rewritten, I can't see this being compatible with serverless SSR.

danielroe avatar Aug 27 '20 17:08 danielroe

For anyone going through this, I don't know if something was fixed but the config below works for me in SSR. The /_content/ API is available too.

{
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder",
      "config": {
        "serverFiles": [
          ".nuxt/content/**",
          "content/**"
        ]
      }
    }
  ]
}

pk992 avatar Jan 10 '21 19:01 pk992

Yes, this is now possible with https://github.com/nuxt/vercel-builder/pull/375

danielroe avatar Jan 10 '21 19:01 danielroe

Hello, I think I got the same problem. In dev mode, I have no problems with nuxt/content. But when I try to build it in order to npm run start, i got problems. You can see here the error which appears in console. image

I tried a lot of methods, i updated my nuxt/content ( i am currently in v1.14.0 for content and my nuxt is v2.15.2).

Do you have an idea ?

Solution

My application is a SPA, so I have to have a 'static' target.

MarquesFlorian avatar Mar 02 '21 15:03 MarquesFlorian

@MarquesFlorian Did you find a fix for this issue?

pxlgrdnr avatar Nov 04 '21 18:11 pxlgrdnr

I don't remember how I solved it but I think that was coming of my "mode Property" of the application. (spa or universal).

@MarquesFlorian Did you find a fix for this issue?

MarquesFlorian avatar Nov 04 '21 18:11 MarquesFlorian

@MarquesFlorian Ah okay. My site was having a similar issue; it was 404'ing on a .json path that did not exist and logged _chain of null. Oddly, Vercel source did show the Nuxt Content folder having some valid JSON just not at the path that the app was trying to load.

pxlgrdnr avatar Nov 05 '21 02:11 pxlgrdnr