Description
Environment
AWS Lambda Node.js 22 (not reproducable locally)
Reproduction
https://github.com/tkgregory/nuxt-content-issue
Deployed environment: https://nuxtissue.tomgregory.com/privacy — repeatedly click the links until you see the error (happens about 50% of the time).
Describe the bug
Steps to reproduce
- Create multiple pages in
/pages
that include Markdown and link to each other e.g.
/pages/privacy.vue
<template>
<main>
<h1 class="text-3xl font-bold mb-8">Privacy</h1>
<div>
<NuxtLink to="/support">Support</NuxtLink>
<NuxtLink to="/privacy">Privacy</NuxtLink>
</div>
<ContentDoc path="/privacy" :head="false" />
</main>
</template>
/pages/support.vue (similar as above)
- Configure nuxt.config.js:
nitro: { preset: "aws_lambda" },
- Deploy to AWS Lambda, serving static content externally via
NUXT_APP_CDN_URL
- View in deployed environment and repeatedly click links between pages.
- Intermittently observe error rendered in HTML page:
{
"message": "You should use slots with <ContentDoc>",
"slot": "default",
"data": [
{
"_path": "/privacy",
"_dir": "",
"_draft": false,
"_partial": false,
"_locale": "",
"title": "Privacy",
"description": "Privacy content goes here",
"body": {
"type": "root",
"children": [
{
"type": "element",
"tag": "p",
"props": {},
"children": [
{
"type": "text",
"value": "Privacy content goes here"
}
]
}
],
"toc": {
"title": "",
"searchDepth": 2,
"depth": 2,
"links": []
}
},
"_type": "markdown",
"_id": "content:privacy.md",
"_source": "content",
"_file": "privacy.md",
"_stem": "privacy",
"_extension": "md"
},
{
"_path": "/support",
"_dir": "",
"_draft": false,
"_partial": false,
"_locale": "",
"title": "Support",
"description": "Support content goes here",
"body": {
"type": "root",
"children": [
{
"type": "element",
"tag": "p",
"props": {},
"children": [
{
"type": "text",
"value": "Support content goes here"
}
]
}
],
"toc": {
"title": "",
"searchDepth": 2,
"depth": 2,
"links": []
}
},
"_type": "markdown",
"_id": "content:support.md",
"_source": "content",
"_file": "support.md",
"_stem": "support",
"_extension": "md"
}
]
}

What I've noticed
When the error occurs, the network tab shows a different response to the XHR API call e.g. https://nuxtissue.tomgregory.com/api/_content/query/bRcR49RreS.1734656338633.json?_params=%7B%22first%22:true,%22where%22:%5B%7B%22_path%22:%22%2Fsupport%22%7D%5D,%22sort%22:%5B%7B%22_stem%22:1,%22$numeric%22:true%7D%5D%7D
The response contains an array of items:
[
{"_path":"/privacy"},
{"_path":"/support"}
]
(truncated for clarity)
When the error doesn't occur, the response includes a single item:
{"_path":"/support"}
(truncated for clarity)
Could be that the response contains an array of items, rather than the specific item, that's causing the issue?
What else?
- No error responses for any network calls
- No errors logged in browser console
- No errors logged on backend
- Works running locally via
npm run dev
- Works running locally via Node.js (without
aws_lambda
Nitro preset) - Works when
NUXT_APP_CDN_URL
is not set
Additional context
View the deployment configuration in severless.yml (uses Serverless Framework).