router.trailingSlash error with static target
See original GitHub issueVersion
@nuxt/content:1.11.1 nuxt: 2.14.12
Reproduction Link
https://codesandbox.io/s/upbeat-hooks-5n26o
Steps to reproduce
- Configure
nuxt.config.js
with{ target: 'static', router: { trailingSlash: true }, ... }
. - Build (
nuxt generate
). - Deploy
dist/
to a real web server (nuxt start
doesn’t exhibit the problem). - 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:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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…
@sts-ryan-holton Somebody more knowledgeable might come along and correct me, but yes I don’t think there is anything that
build
does thatgenerate
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 .