nuxtent-module icon indicating copy to clipboard operation
nuxtent-module copied to clipboard

404 on refresh post

Open influx-agence opened this issue 6 years ago • 7 comments

Describe the bug Hello, That's my problem: When I go to my blog, the list of articles is displayed well. Once I go to an article and refresh the page I find a 404 error. Looking more ready the networks I realize that the .JSON normally called has two points after refreshment (Myurl.com/_nuxt/content/name..json) Someone will have an idea where it might come from? Thx for your rep :+1:

To Reproduce

  1. Go to 'https://influx-agence.netlify.com/blog/'
  2. Click on 'My second blog'
  3. Look the web console network ( 2018.premier-posts.json )
  4. Refresh page
  5. The page is 404
  6. Look web console network ( 2018.premier-posts**..**json )

Screenshots 3. Before refresh image 6. After refresh image

Applicable Versions:

  • Nuxt : Last
  • Netlify CMS : Last
  • Node.JS : 8.12.0

CMS configuration

backend:
  name: github
  repo: influx-agence/Nuxtlify
  branch: master
media_folder: "static/uploads"
display_url: https://influx-agence.netlify.com
collections: # A list of collections the CMS should be able to edit
  - name: "blog" # Used in routes, ie.: /admin/collections/:slug/edit
    label: "Blog" # Used in the UI, ie.: "New Post"
    folder: "content/posts"
    extension: "json"
    format: "json"
    create: true
    slug: "{{year}}-{{slug}}"
    fields: # The fields each document in this collection have
      - {label: "Title", name: "title", widget: "string", tagname: "h1"}
      - {label: "Publish Date", name: "date", widget: "datetime", format: "DD-MM-YYYY"}
      - {label: "Cover Image", name: "image", widget: "image", required: false, tagname: ""}
      - {label: "Body", name: "body", widget: "markdown"}
    meta:
- {label: "SEO Description", name: "description", widget: "text"}

Additional context https://github.com/influx-agence/Nuxtlify

This question is available on Nuxt community (#c7729)

influx-agence avatar Sep 13 '18 09:09 influx-agence

This is a Nuxt 404, it doesn't seem to be specific to the Nuxtend module.

What I assume happens is this:

  • You land on https://influx-agence.netlify.com/blog/ and Nuxt bootstraps in SPA mode
  • You then click on the blog link. Client-side routing kicks in, so Nuxt knows what to serve you
  • Now you reload the page. The request arrives server-side, but there is no route for this page, so you get a 404

To fix this, you have two options:

  • Manually define a route for every blog post (not very practical)
  • Rewrite all requests to be served by your root page so that Nuxt can bootstrap

The latter is the common approach. You can find an example of how to do that in the Netlify documentation: https://www.netlify.com/docs/redirects/#history-pushstate-and-single-page-apps

I am fairly confident that will fix your issue. Although to be honest, I would have been more confident if it was a Netlify 404.

joostdecock avatar Sep 13 '18 09:09 joostdecock

Okay i create _redirects in my static folder

The problem remains the same. I'm no more error 404 but the .json still has two points ..

image

influx-agence avatar Sep 17 '18 09:09 influx-agence

@influx-agence as I pointed out in here, the problem was that nuxtent does not support json file types, just changing it to markdown format and using a yaml frontmatter format fixed the issue, also you can use a yaml format for your data or even mixing it.

cesasol avatar Sep 18 '18 05:09 cesasol

Like this ? ( thx cesasol for rep :) ) image Update 19/09 : Same problem

influx-agence avatar Sep 18 '18 15:09 influx-agence

Sorry but I don't know anything about netlify cms

cesasol avatar Sep 20 '18 18:09 cesasol

up

influx-agence avatar Sep 23 '18 09:09 influx-agence

Has anyone found a work-around? This is definitely a Nuxtent issue apparent with static generated MD content. All the content fails to refresh or load directly with the 404 trying to load post name..json (notice the two dots)

chadananda avatar Jan 31 '19 22:01 chadananda