# S3 with CDN image link broken on user card and profile background

**URL:** https://meta.discourse.org/t/s3-with-cdn-image-link-broken-on-user-card-and-profile-background/29286
**Category:** Bug
**Tags:** uploads, cdn
**Created:** [May 27, 2015, 1:13am UTC](https://meta.discourse.org/t/s3-with-cdn-image-link-broken-on-user-card-and-profile-background/29286 "2015-05-27T01:13:40Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![wub](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wub/32/42488_2.png) [@wub](https://meta.discourse.org/u/wub)
#### Post date: [May 27, 2015, 1:13am UTC](https://meta.discourse.org/t/s3-with-cdn-image-link-broken-on-user-card-and-profile-background/29286/1 "2015-05-27T01:13:40Z")

</div>

On my site (let’s say `foo.com`), I have a “Discourse CDN” set up (`cdn.foo.com`) to serve JS/CSS. Uploads to S3 are also enabled, and the S3 CDN is `storage.foo.com`. My raw S3 bucket is `foo.s3.amazonaws.com`.

On the user profile image, the S3 cdn gets appended to the Discourse CDN: `//cdn.foo.com//storage.foo.com/xxxxx.jpg`

The user _card_ image, on my site appends raw S3 bucket to the Discourse CDN: `//cdn.foo.com//foo.s3.amazonaws.com/xxxxx.jpg`

I’ve tried rebakes etc., is there anything else I need to do, or is this a bug?

[This commit](https://github.com/discourse/discourse/commit/6a68e8c27284b542e344ea3b1a8d81311b62e39c) might be related.

---

<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: [May 27, 2015, 1:52am UTC](https://meta.discourse.org/t/s3-with-cdn-image-link-broken-on-user-card-and-profile-background/29286/2 "2015-05-27T01:52:43Z")

</div>

What do you think @sam? This is probably very fresh in your mind…

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 27, 2015, 2:04am UTC](https://meta.discourse.org/t/s3-with-cdn-image-link-broken-on-user-card-and-profile-background/29286/3 "2015-05-27T02:04:48Z")

</div>

Post this it works:

[https://github.com/discourse/discourse/commit/a988cd5abeaeff94463027f02dded5aa3ee9f372](https://github.com/discourse/discourse/commit/a988cd5abeaeff94463027f02dded5aa3ee9f372)

However we need to change our storage schema for S3 optimized images (and all optimised images) to allow us to send avatar templates down to the client to avoid the redirection.

---

<div class="post-metadata">

### Author: ![wub](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wub/32/42488_2.png) [@wub](https://meta.discourse.org/u/wub)
#### Post date: [May 27, 2015, 2:33am UTC](https://meta.discourse.org/t/s3-with-cdn-image-link-broken-on-user-card-and-profile-background/29286/4 "2015-05-27T02:33:46Z")

</div>

Thanks, Sam, that fixes the avatar issues.

I’m still having the same issue with profile headers/cards, though. I’d turn the S3 CDN off, but direct S3 access is so slow here in NZ!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 27, 2015, 2:36am UTC](https://meta.discourse.org/t/s3-with-cdn-image-link-broken-on-user-card-and-profile-background/29286/5 "2015-05-27T02:36:35Z")

</div>

confirmed, I can see the bug … its a different bug … will fix

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 27, 2015, 3:00am UTC](https://meta.discourse.org/t/s3-with-cdn-image-link-broken-on-user-card-and-profile-background/29286/6 "2015-05-27T03:00:44Z")

</div>

lets try this then:

[https://github.com/discourse/discourse/commit/24102f26365d08208702061d13adb93c76d058f3](https://github.com/discourse/discourse/commit/24102f26365d08208702061d13adb93c76d058f3)

---

<div class="post-metadata">

### Author: ![wub](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wub/32/42488_2.png) [@wub](https://meta.discourse.org/u/wub)
#### Post date: [May 27, 2015, 3:31am UTC](https://meta.discourse.org/t/s3-with-cdn-image-link-broken-on-user-card-and-profile-background/29286/7 "2015-05-27T03:31:59Z")

</div>

Thanks! That solved it.

I now have the issue that when I try to upload a custom avatar, it tries to load it from: `//foo.s3-us-east-1.amazonaws.com/original/4/f/xxx.jpeg` when it used to be `foo.s3.amazonaws.com`. My S3 region is `us-east-1` in the Discourse admin (I assume it used to try load it from “US Standard”)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 27, 2015, 3:37am UTC](https://meta.discourse.org/t/s3-with-cdn-image-link-broken-on-user-card-and-profile-background/29286/8 "2015-05-27T03:37:34Z")

</div>

That’s unrelated, but it seems to me that your existing uploads are in the wrong spot, open a bug on it

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 27, 2015, 3:37am UTC](https://meta.discourse.org/t/s3-with-cdn-image-link-broken-on-user-card-and-profile-background/29286/9 "2015-05-27T03:37:36Z")

</div>


