我们使用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
??
1条答案
按热度按时间pgx2nnw81#
结果我们在
next.config.js
中调优了这个实验特性,当它打开时。env变量都是未定义的,并且在getStaticPaths
中没有正确加载,但是一旦调用getStaticProps
,一切都很好,我不知道为什么,但是关闭workerThreads
解决了这个问题: