我现在花了两天时间,试图弄清楚为什么Facebook Sharing Debugger无法正确获取我的next.js网站。该网站托管在Vercel上。
当我用Postman或浏览器获取它时,没有错误(在Vercel日志和控制台中)。服务器返回HTML和状态码200。但是,当我使用Facebook共享调试器获取它时: See exactly what our scraper sees for your URL我得到了:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>
<body><p>An error occurred with this application.
NO_STATUS_CODE_FROM_FUNCTION
</p></body>
</html>
响应代码为502。
Vercel控制台显示此错误:
[GET] /
23:19:43:38
Status:
-1
Duration:
2881.85ms
Memory Used:
54 MB
ID:
jkth8-1589318383376-c2fb8a7f81a0
User Agent:
facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
2020-05-12T21:19:46.290Z a0145e40-064f-4313-9d63-068d4fd882c7 WARN the options [servers] is not supported
2020-05-12T21:19:46.290Z a0145e40-064f-4313-9d63-068d4fd882c7 WARN the options [caseTranslate] is not supported
2020-05-12T21:19:46.290Z a0145e40-064f-4313-9d63-068d4fd882c7 WARN the options [dbName] is not supported
2020-05-12T21:19:46.290Z a0145e40-064f-4313-9d63-068d4fd882c7 WARN the options [srvHost] is not supported
2020-05-12T21:19:46.290Z a0145e40-064f-4313-9d63-068d4fd882c7 WARN the options [credentials] is not supported
2020-05-12T21:19:46.291Z a0145e40-064f-4313-9d63-068d4fd882c7 ERROR Uncaught Exception {"errorType":"Error","errorMessage":"ENOENT: no such file or directory,open './public/fact-title-img-8bf01afa.jpeg'","code":"ENOENT","errno":-2,"syscall":"open","path":"./public/fact-title-img-8bf01afa.jpeg","stack":["Error: ENOENT: no such file or directory,open './public/fact-title-img-8bf01afa.jpeg'"]}
Unknown application error occurred
该错误与我的函数有关,该函数将从MongoDB提取的二进制数据作为文件保存在public
文件夹中,因此可以在react组件中使用它。
这到底是怎么回事?为什么Facebook GET和Postman GET的工作原理有所不同?