# 定义 DISCOURSE\_S3\_CDN\_URL 以链接 S3 CDN URL 中的资源

**URL:** <https://meta.discourse.org/t/defining-discourse-s3-cdn-url-links-to-assets-in-s3-cdn-url/116798>\
**Category:** Support\
**Created:** [2019年五月3日 21:44 UTC](https://meta.discourse.org/t/defining-discourse-s3-cdn-url-links-to-assets-in-s3-cdn-url/116798 "2019-05-03T21:44:07Z")\
**Posts on this page:** 1\
**Showing post:** 31

<div class="post-metadata">

**Author:** ![eatcodetravel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eatcodetravel/32/94385_2.png) [@eatcodetravel](https://meta.discourse.org/u/eatcodetravel)\
**Post date:** [2020年三月4日 18:55 UTC](https://meta.discourse.org/t/defining-discourse-s3-cdn-url-links-to-assets-in-s3-cdn-url/116798/31 "2020-03-04T18:55:09Z")

</div>

我想这是因为你缺少 `DISCOURSE_CDN_URL`。我们的配置如下：

```plaintext
DISCOURSE_CDN_URL: 'https://d16zv78c963s69.cloudfront.net' # 指向服务器
DISCOURSE_S3_CDN_URL: 'https://community-cdn-prod.debtcollective.org' # 指向 S3 存储桶

```

样式表从服务器获取，因此使用 `DISCOURSE_CDN_URL`。JavaScript 文件上传到 S3 存储桶，并使用 `DISCOURSE_S3_CDN_URL`。@Falco 在这里向我解释了这一点。

> [@Assets not serving from CDN in latest update](https://meta.discourse.org/t/assets-not-serving-from-cdn-in-latest-update/140705/13?u=eatcodetravel):
>
> If you inspect this page you will see that we we have two different Cloudfront URLs, so we use what I said above, two distributions, one for the normal CDN and another for S3. The problem from the title of the OP is this: CSS come from the app and JS from S3. You need a CDN that is aware of where every single asset is coming from and can reach the necessary place or two CDNs. That is why we have two different settings after all.

---

_[View the full topic](https://meta.discourse.org/t/defining-discourse-s3-cdn-url-links-to-assets-in-s3-cdn-url/116798)._
