我们使用next.js与knext .js作为查询生成器,在所有页面中一切都是OK的,除了在一个页面中,我们有ISR akagetStaticPaths
,并且在该方法中,每当我们试图执行查询时,我们都会得到以下错误,但在其他页面中,没有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
之外的任何地方都能正确读取??
原来我们在next.config.js
中打开了这个实验功能,当它打开时。env变量都是未定义的,并且没有在getStaticPaths
中正确加载,但是一旦getStaticProps
被称为一切正常,我不知道原因,但是关闭workerThreads
解决了问题:
experimental: {
workerThreads: false //fixed the problem
},