解决NuxtContent在Vercel无数据库部署时queryCollection无法使用
2025-12-2511 mins readfrontendtutorialvue
一些相关的 issue #2378 #3548 但是好像和我的情况也并不是完全一样
错误分析
在 NuxtConent文档 中写到
Nuxt Content projects can be deployed to Vercel with zero configuration. The module will automatically detect a Vercel environment and will prepare the necessary configuration for deployment.
By default module will use SQlite database in Vercel located at /tmp directory.
但是用起来根本不是这么回事, 当第一次访问网站或刷新的时候, 执行服务端渲染, queryCollection 会报错
plaintext
loading...
但是如果手动切换一下路由, 此时是客户端渲染, queryCollection 会使用客户端的数据库查询, 就能正常使用, 所以一定是服务端的数据库出了问题.
解决方法
结果多次测试发现, 只要手动指定一下 database 就可以用了
file=nuxt.config.ts
loading...
--- 评论区施工中🚧 ---