Amazon web services Next.js/api serverless上的setPreviewData抛出错误(不是函数)
我使用next.js表示sanity.io中的数据,并将其部署为AWS上的无服务器应用程序(边缘优化)。起初,这个功能是有效的,但在某个时候,它只是停止了对aws部署的工作,我只是“弄清楚它是什么”。上http://localhost:3000 它仍然在工作 我使用官方的next.js指南来实现 这是该代码的一个简单版本Amazon web services Next.js/api serverless上的setPreviewData抛出错误(不是函数),amazon-web-services,next.js,serverless,aws-serverless,sanity,Amazon Web Services,Next.js,Serverless,Aws Serverless,Sanity,我使用next.js表示sanity.io中的数据,并将其部署为AWS上的无服务器应用程序(边缘优化)。起初,这个功能是有效的,但在某个时候,它只是停止了对aws部署的工作,我只是“弄清楚它是什么”。上http://localhost:3000 它仍然在工作 我使用官方的next.js指南来实现 这是该代码的一个简单版本 export default async function handler(req, res) { // code that checks that that the re
export default async function handler(req, res) {
// code that checks that that the request is correct here, it works
console.log('about to call setPreviewData', res.setPreviewData.toString());
// the previous log command is called and this is how the function is logged
// (data,options= {} )=>setPreviewData(apiRes,data,Object.assign({} apiContext,options))
res.setPreviewData({})
// the function crashes between the previous and this log
console.log('Location to go to', `/${req.query.slug}`)
res.writeHead(307, {
Location: `/${post.type}/${post.slug}`
})
res.end()
}
相关依赖关系
"next": "^10.0.3",
"serverless-next.js": "^1.15.0-alpha.2",
"serverless-nextjs-plugin": "^2.5.2-alpha.0"
开发依赖项
"next": "^10.0.3",
"serverless-next.js": "^1.15.0-alpha.2",
"serverless-nextjs-plugin": "^2.5.2-alpha.0"
更奇怪的是,在同一个api文件夹中,我有一个退出预览功能
export default async function handler(_, res) {
res.clearPreviewData()
res.writeHead(307, { Location: '/' })
res.end()
}
我已经检查了CloudFront配置,并且“转发cookie”已打开
在Cloudwatch中,我得到了一系列关于e[t]不是函数的错误
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "TypeError: e[t] is not a function",
"reason": {
"errorType": "TypeError",
"errorMessage": "e[t] is not a function",
"stack": [
"TypeError: e[t] is not a function",
" at __webpack_require__ (/var/task/pages/api/previewArticle.js:7249:30130)"
...
有人对我可以尝试什么有什么建议吗?谢谢:)