【问题标题】:Fetching the website with Facebook Sharing Debugger causes an error使用 Facebook 共享调试器获取网站会导致错误
【发布时间】:2020-08-28 22:10:33
【问题描述】:

我现在花了两天时间,试图弄清楚为什么 Facebook 共享调试器无法正确获取我的 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 文件夹中,因此我可以在反应组件中使用它。

这到底是怎么回事?为什么 facebook GET 与 Postman GET 的工作方式不同?

【问题讨论】:

    标签: facebook facebook-like next.js vercel


    【解决方案1】:

    解决方案很简单。我在 fs.writeFile 回调中安全地返回一个错误,而不是抛出它来终止进程。 我不知道为什么只有在 facebook 获取网站时才会发生错误。

    【讨论】:

      猜你喜欢
      • 2017-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-22
      相关资源
      最近更新 更多