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.

router.trailingSlash error with static target

See original GitHub issue

Version

@nuxt/content:1.11.1 nuxt: 2.14.12

Reproduction Link

https://codesandbox.io/s/upbeat-hooks-5n26o

Steps to reproduce

  1. Configure nuxt.config.js with { target: 'static', router: { trailingSlash: true }, ... }.
  2. Build (nuxt generate).
  3. Deploy dist/ to a real web server (nuxt start doesn’t exhibit the problem).
  4. Navigate to a content page.

What is Expected?

The content page loads normally.

What is actually happening?

The content page appears in the browser but fails to hydrate. The console has this:

TypeError: e.page is undefined
    NuxtJS 81
        component
        _render
        r
        get
        _n
        mount
        $mount
        init
        n
        R
        bo
        _update
        r
        get
        _n
        mount
        $mount
        init
        R
        bo
        _update
        r
        get
        _n
        mount
        $mount
        init
        R
        R
        bo
        _update
        r
        get
        _n
        mount
        $mount
        init
        R
        R
        bo
        _update
        r
        get
        _n
        mount
        $mount
        init
        R
        R
        bo
        _update
        r
        get
        _n
        mount
        $mount
        c
        e
        d
        _invoke
        O
        r
        l
        promise callback*r
        l
        promise callback*r
        h
        promise callback*r
        l
        o
        o
        I
        170
        promise callback*170/<
        170
        l
        168
        l
        t
        r
        <anonymous>

This occurs with a generic page like this:

<template>
  <div>
    <nuxt-content :document="page"/>
  </div>
</template>

<script>
export default {
  async asyncData({ $content, params, error }) {
    const slug = params.slug || "index";
    const page = await $content(slug)
      .fetch()
      .catch(err => {
        error({ statusCode: 404, message: "Page not found" });
      });

    return {
      page,
    };
  },
  mounted() {
    console.log(this.page);    // <-- undefined
  },
};
</script>

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
divinecommented, Jan 7, 2021

There is definitely some weird things going with trailingSlash: true and nuxt content.

See https://github.com/nuxt/content/pull/690 it’s one of those bugs, it should be handled by nuxt itself…

0reactions
chazmcgarveycommented, Jan 6, 2021

@sts-ryan-holton Somebody more knowledgeable might come along and correct me, but yes I don’t think there is anything that build does that generate won’t also accomplish.

As to the performance of your site, the likeliest issue is probably just large build artifacts with unused styles or code. The output of build makes it easy to see those. I myself had such issues by bringing in Buefy, a large UI component library, but I’ve had success reducing filesizes with two techniques: 1) custom stylesheet importing only what I’m using, and 2) nuxt-purgecss .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fixing the trailing slash in Static Site Generation
An issue with prerendering, Angular or other, is that it creates an index.html file inside a route folder. The default behavior of different ......
Read more >
Prevent AWS Amplify From Adding Trailing Slash and Forcing ...
Amplify adds a trailing slash to prevent urls like /about.html but that's probably not the real cause. Your app/browser is making requests ...
Read more >
URL Routing — Werkzeug Documentation (2.2.x)
from werkzeug.routing import Map, Rule, NotFound, RequestRedirect url_map ... URL without a trailing slash will redirect to the URL with a slash appended....
Read more >
Trailing Slashes and Gatsby - Jon
You can go through similar steps to force trailing slashes for any client-side-only routes you've made by pulling in the Reach Router for ......
Read more >
Trailing slash missing on proxied Netlify site - Support
Trailing slash missing on proxied Netlify site ... You'll want to check out the section “my SSG uses static routing” which explains exactly...
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