请求代理
通过你自己的服务器代理请求 EAS 更新服务器。
EAS Update 支持请求代理,允许你通过自己的服务器将请求代理到 EAS Update 服务器。这有很多用途,例如添加自定义标头、记录请求或实现额外的安全措施或请求 IP 匿名化措施。
¥EAS Update supports request proxying, which allows you to proxy requests to the EAS Update server through your own server. This can be useful for various reasons, such as adding custom headers, logging requests, or implementing additional security or request IP anonymization measures.
启用请求代理
¥Enabling request proxying
-
创建两个用于处理请求的代理服务器:
¥Create two proxy servers that will handle the requests:
-
一个用于更新资源请求(JavaScript 包、图片等)。
¥One for the update asset requests (JavaScript bundles, images, and so on).
-
这必须将请求转发到
assets.eascdn.net
,即 EAS 更新资源服务器。¥This must forward requests to
assets.eascdn.net
, the EAS Update asset server. -
这必须传递所有 URL 内容(路径、查询参数等)。
¥This must pass-through all URL contents (path, query parameters, and so on).
-
这必须传递所有以
expo-
或eas-
为前缀的标头。¥This must pass-through all headers prefixed with
expo-
oreas-
.
-
-
一个用于更新清单请求。
¥One for the update manifest requests.
-
这必须将请求转发到
u.expo.dev
,即 EAS 更新服务器。¥This must forward requests to
u.expo.dev
, the EAS Update server. -
这必须传递所有 URL 内容(路径、查询参数等)。
¥This must pass-through all URL contents (path, query parameters, and so on).
-
这必须传递所有以
expo-
或eas-
为前缀的标头。¥This must pass-through all headers prefixed with
expo-
oreas-
.
-
-
-
将以下字段添加到你的 eas.json 配置文件中,并将占位符替换为你的实际代理服务器 URL:
¥Add the following fields to your eas.json configuration file, replacing the placeholders with your actual proxy server URLs:
{ "cli": { %%placeholder-start%%... %%placeholder-end%% "updateAssetHostOverride": "updates-asset-proxy.example.com", "updateManifestHostOverride": "updates-manifest-proxy.example.com" } }
-
运行以下命令应用更改:
¥Run the following command to apply the changes:
-
eas update:configure
-
发布更新以测试代理:
¥Publish an update to test the proxying:
-
eas update
-
通过导航到 EAS 更新仪表板 上的更新组并点击其中一个平台的 "查看元数据" 进行验证。
¥Verify by navigating to the update group on the EAS Update dashboard and clicking "View Metadata" for one of the platforms.
-
manifest.json 应该会显示已覆盖的
manifestHostOverride
。¥manifest.json should show the overridden
manifestHostOverride
. -
其他资源应显示已覆盖的
assetHostOverride
。¥Other assets should show the overridden
assetHostOverride
.
-