# 亚马逊链接无法单框显示

**URL:** <https://meta.discourse.org/t/amazon-links-are-failing-to-onebox/181942>\
**Category:** Bug\
**Created:** [2021年三月3日 22:48 UTC](https://meta.discourse.org/t/amazon-links-are-failing-to-onebox/181942 "2021-03-03T22:48:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [2021年三月3日 22:48 UTC](https://meta.discourse.org/t/amazon-links-are-failing-to-onebox/181942/1 "2021-03-03T22:48:05Z")

</div>

亚马逊链接无法生成单盒预览，并返回 `503` 错误。此问题已在某客户网站上被报告。我能够在 Meta 环境以及我们的沙盒站点上复现该问题：[https://try.discourse.org/t/amazon-onebox-tests/1406。我特意在沙盒站点上进行了测试，以排除因](https://try.discourse.org/t/amazon-onebox-tests/1406%E3%80%82%E6%88%91%E7%89%B9%E6%84%8F%E5%9C%A8%E6%B2%99%E7%9B%92%E7%AB%99%E7%82%B9%E4%B8%8A%E8%BF%9B%E8%A1%8C%E4%BA%86%E6%B5%8B%E8%AF%95%EF%BC%8C%E4%BB%A5%E6%8E%92%E9%99%A4%E5%9B%A0) Meta 环境缓存单盒数据而导致的误报。不过，以下链接应能展示该问题：

`https://www.amazon.com/Moog-Grandmother-Semi-Modular-Keyboard-Synthesizer/dp/B07FJF9TLJ/ref=pd_sbs_5`

> **[Amazon.com: MOOG Grandmother Semi-Modular Analog Keyboard Synthesizer with 32...](https://www.amazon.com/Moog-Grandmother-Semi-Modular-Keyboard-Synthesizer/dp/B07FJF9TLJ)**
>
> Inspired by the classic MOOG modular synthesizers that came before it, Grandmother's sound engine, modulation engine and onboard spring reverb tank are completely analog, resulting in an unrestricted sonic vocabulary of immeasurable beauty and power....

在我的本地开发站点上，上述链接可以正常转换为单盒预览，没有任何问题。生产环境中的问题可能与单盒功能所使用的用户代理（user agent）有关。我认为在开发模式下并未设置该用户代理。

---

<div class="post-metadata">

**Author:** ![jamie.wilson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamie.wilson/32/185466_2.png) [@jamie.wilson](https://meta.discourse.org/u/jamie.wilson)\
**Post date:** [2021年三月3日 23:58 UTC](https://meta.discourse.org/t/amazon-links-are-failing-to-onebox/181942/3 "2021-03-03T23:58:03Z")

</div>

> <https://github.com/discourse/onebox/pull/457>
>
> We use a custom user agent when making requests against various Amazon propertie…s. However, the user agent is quite old which may be a cause of 503 errors that users are noticing when oneboxing Amazon URLs.
> 
> Updating this user agent to a current/more popular user agent may help avoid these errors.

Onebox 目前在对多个亚马逊网站发起请求时会发送自定义用户代理。不过，我们发送的用户代理版本非常旧，并不常见。

我已创建一个简单的拉取请求（PR），将用户代理更新为更现代的版本。这或许有助于解决 503 错误。

但请注意，在对此次更改进行手动测试期间，我无法确定触发 503 错误的具体模式。在许多情况下，使用旧用户代理会导致 503 错误，但有时却不会。因此，我不能保证这能彻底解决问题，但我认为这将在一定程度上有助于减少错误数量。

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2021年三月21日 08:00 UTC](https://meta.discourse.org/t/amazon-links-are-failing-to-onebox/181942/4 "2021-03-21T08:00:31Z")

</div>

本主题已在 13 天后自动关闭，不再接受新回复。
