next.js 错误:getaddrinfo ENOTFOUND在特定页面上未定义

ajsxfq5m  于 2022-12-23  发布在  其他
关注(0)|答案(1)|浏览(135)

我们使用next.js和knex.js作为查询生成器,在所有页面中一切正常,除了一个页面,我们有ISR aka getStaticPaths,在该方法中,每当我们尝试执行查询时,我们会得到以下错误,但在其他页面中,没有getStaticPaths一切正常:

Server Error
Error: getaddrinfo ENOTFOUND undefined

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
GetAddrInfoReqWrap.onlookup [as oncomplete]
node:dns (71:26)

没有更多的信息是提供任何其他地方.因为它是显示在这错误讯息,这数据库主机是未定义的,但为什么它正确地读取到处除了在getStaticPaths??

pgx2nnw8

pgx2nnw81#

结果我们在next.config.js中调优了这个实验特性,当它打开时。env变量都是未定义的,并且在getStaticPaths中没有正确加载,但是一旦调用getStaticProps,一切都很好,我不知道为什么,但是关闭workerThreads解决了这个问题:

experimental: {
    workerThreads: false //fixed the problem
},

相关问题