API 路由

了解如何在 EAS Hosting 仪表板上检查来自 API 路由的请求。


信息 本页面包含关于 EAS 托管的 API 路由的具体细节。有关该主题的一般文档,请参阅 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.logconsole.infoconsole.error 等)的所有日志都会记录在部署级别的日志页面上。前往 Hosting 部署 > 选择一个部署 > 日志

🌐 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

可以在项目层级查看请求,请访问 Hosting requests,在部署层级查看请求,请访问 Hosting Deployments > 选择一个部署 > 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.

通过 ID 查找请求

🌐 Looking up a request by ID

所有响应头都包含一个看起来像 8ffb63895cf6779b-LHRCf-Ray 头。它的第一部分是请求 ID,你可以通过使用 Hosting > Requests 中的筛选器,在 EAS 仪表板上通过此 ID 查找请求。

🌐 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 托管记录的数据将会被降采样。这意味着随着你的部署接收更多请求,记录的数据点将会减少,你可能无法看到单个请求、日志和崩溃逐一列出。然而,统计计数,例如请求次数或崩溃次数,将会被估算,以仍然按比例反映所有请求。

🌐 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.