# Defining DISCOURSE\_S3\_CDN\_URL links to assets in S3 CDN URL

**URL:** <https://meta.discourse.org/t/defining-discourse-s3-cdn-url-links-to-assets-in-s3-cdn-url/116798>\
**Category:** Product Support\
**Created:** [5월 3, 2019, 9: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:** 1

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [5월 3, 2019, 9:44오후 UTC](https://meta.discourse.org/t/defining-discourse-s3-cdn-url-links-to-assets-in-s3-cdn-url/116798/1 "2019-05-03T21:44:07Z")

</div>

I had this problem before and decided that I was crazy, confused, or the database on the site was suspect, but this is on a brand new site. Also, I was on Digital Ocean spaces, so I thought it might be a problem somehow.

I’m trying again to figure out how to keep images on AWS S3 like I think the Big Boys do.

Here’s what I have in the `env` section:

```plaintext
  DISCOURSE_S3_ACCESS_KEY_ID: 'key'
  DISCOURSE_S3_SECRET_ACCESS_KEY: 'lock'
  DISCOURSE_BACKUP_LOCATION: 's3'
  DISCOURSE_S3_BUCKET: 'lc-xyz'
  DISCOURSE_S3_BUCKET_NAME: 'lc-xyz'
  DISCOURSE_S3_BACKUP_BUCKET: 'lc-xyz/backups'
  DISCOURSE_S3_UPLOAD_BUCKET: 'lc-xyz/uploads'
  DISCOURSE_S3_CDN_URL: 'https://lc-rbx.s3.amazonaws.com'

```

When I include the `s3 cdn url` the site breaks because all of the links to the assets are on S3 like `https://lc-xyz.s3.amazonaws.com/assets/plugin-third-party-01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b.br.js`.

> [@Digital Ocean Spaces don’t implement the AWS S3 API for the CORS rule](https://meta.discourse.org/t/digital-ocean-spaces-don-t-implement-the-aws-s3-api-for-the-cors-rule/111736/2):
>
> Why do you need to push assets to S3? Can’t they be served from a push CDN like normal? Uploads assets means JS files not uploads.

Because if you define `s3 cdn url` Discourse looks for the assets on the s3\_cdn\_url.

I did a rebuild, but the assets are still missing. I can do a

```
rake s3:upload_assets

```

Is there an `after_bundling_assets` stanza that I could add that to? (I know about `after_db_migrate` and `after_bundle_exec`, but don’t know if those would work.)

Do assets get produced some other time? (It would seem like when themes get modified assets would change.)

If I also had a “push CDN like normal”, would that keep this from happening?

Is there some best practice that I’m missing?

---

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