了解如何在 EAS Hosting 仪表板上检查来自 API 路由的请求。
此页面用于有关 API 路由的 EAS Hosting 特定详细信息。有关该主题的一般文档,请参阅 Expo Router 下的 API 路由 文档。
可以在 EAS Hosting 仪表板上检查 API 路由中发生的崩溃、日志和请求。
¥Crashes, logs, and requests that occur in API routes can be inspected on the EAS Hosting dashboard.
¥Crashes
崩溃是处理请求时抛出的任何未捕获的错误,这会阻止返回响应,例如 throw new Error("An error!")
。可以在 托管崩溃 页面上查看崩溃。
¥A crash is any uncaught error that is thrown while a request was handled, which prevented a response from being returned, for example, throw new Error("An error!")
. Crashes may be viewed on the Hosting crashes page.
崩溃已分组。如果检测到类似的崩溃,你将只看到一行项目。崩溃详细信息将显示第一次和最后一次已知崩溃发生的堆栈跟踪和元数据。
¥Crashes are grouped. If similar crashes are detected, you will see just one line item for them. The crash details will show the stack trace and metadata for the first and last known occurrence of the crash.
¥Logs
来自 API 路由和服务器功能(console.log
、console.info
、console.error
等)的所有日志都记录在部署级别日志页面。转到 托管部署 > 选择部署 > 日志。
¥All logs from API routes and server functions (console.log
, console.info
, console.error
, and so on) are recorded on the deployment level logs page. Go to Hosting deployments > select a deployment > Logs.
¥Requests
可以在项目级别 托管请求 和部署级别 托管部署 > 选择部署 > 请求中查看请求。
¥Requests can be viewed on the project level at Hosting requests and deployment level Hosting Deployments > select a deployment > Requests.
这将显示针对你的服务的请求列表,每个请求包含元数据(状态、浏览器、区域、持续时间等)。这些包括对服务的所有请求,包括对 API 路由的请求。
¥This will show a list of requests against your service, with metadata (status, browser, region, duration, and more) per request. These include all requests to the service, including requests to API routes.
¥Looking up a request by ID
所有响应标头都包含一个类似于 8ffb63895cf6779b-LHR
的 Cf-Ray
标头。第一部分是请求 ID,你可以使用 托管请求 中的过滤器通过此 ID 在 EAS 仪表板上查找请求。
¥All response headers include a Cf-Ray
header that looks like 8ffb63895cf6779b-LHR
. The first part of this is the request ID and you may look up the request on the EAS dashboard via this ID using the filters in Hosting Requests.
此请求 ID 也会显示在任何服务级错误页面上。
¥This request ID is also displayed on any service-level error pages.
¥Sampling
如果部署收到大量流量,EAS Hosting 记录的数据将为 downsampled。这意味着随着你的部署收到更多请求,记录的数据点将减少,并且你可能看不到逐一列出的单个请求、日志和崩溃。但是,统计计数(例如请求数或崩溃次数)将估计为仍按比例反映所有请求。
¥If a deployment receives a high amount of traffic, data that EAS Hosting records will be downsampled. This means as your deployments receive more requests, fewer data points will be recorded, and you may not see individual requests, logs, and crashes be listed one by one. However, statistical counts, such as number of requests or crashes, will be estimated to still reflect all requests proportionally.