# Update URLs inside a poll after changing CDN

**URL:** https://meta.discourse.org/t/update-urls-inside-a-poll-after-changing-cdn/405198
**Category:** Support
**Tags:** polls
**Created:** [June 12, 2026, 5:19pm UTC](https://meta.discourse.org/t/update-urls-inside-a-poll-after-changing-cdn/405198 "2026-06-12T17:19:32Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [June 12, 2026, 5:19pm UTC](https://meta.discourse.org/t/update-urls-inside-a-poll-after-changing-cdn/405198/1 "2026-06-12T17:19:33Z")

</div>

I have created a poll on my forum like:

```plaintext
[poll name=freestyle type=multiple results=always min=1 max=14 public=true chartType=bar]
* **#1**![DSC_2281.jpg|332x500, 33%](upload://ujMDcnd4syevNGdEN2O1qUTeWeK)
* **#2**![IMG_3248.jpg|690x459, 33%](upload://tsecEjlruXEpg3faidWmENBupM4)
[/poll]

```

I migrated from a CDN to no CDN, and the URLs were changed from `cdn.unicyclist.com` to `unicyclist.com`.

However, the images URLs here remains broken, despite appearing in the post preview:

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/5/6/f56c97e36017c0097a87f79f7d2093d93d8354e8.jpeg)

Rebaking posts and running `rake 'posts:remap[cdn.unicyclist.com,unicyclist.com]'` didn’t fix it.

[ask.discourse.org](http://ask.discourse.org) advises:

> ## What’s probably happening
> 
> Your poll options are not only in the post raw. On your site schema, polls also store rendered option HTML in:
> 
> - `polls`
> - `poll_options.html`
> 
> So the post preview can look fine, but the poll renderer may still be using stale HTML with the old CDN hostname.
> 
> Related docs:
> 
> - [Creating and managing polls](https://meta.discourse.org/t/creating-and-managing-polls/77548)
> - [Remove DISCOURSE\_CDN\_URL](https://meta.discourse.org/t/remove-discourse-cdn-url/148096)
> - [Disable CDN causes old images with CDN URL can not be shown](https://meta.discourse.org/t/disable-cdn-causes-old-images-with-cdn-url-can-not-be-shown/29657)
> - [Replace a string in all posts](https://meta.discourse.org/t/replace-a-string-in-all-posts/48729)
> 
> ## Important warning
> 
> **Take a full backup first.**
> 
> Also, avoid “just editing” the poll if it has votes, because poll edits normally clear votes:
> 
> - [Creating and managing polls — Can polls be edited?](https://meta.discourse.org/t/creating-and-managing-polls/77548)
> 
> ## Safer approach: inspect one broken poll first
> 
> In the container:
> 
> ```bash
> cd /var/discourse
> ./launcher enter app
> rails c
> 
> ```
> 
> Then find the poll for that post:
> 
> ```rb
> poll = Poll.find_by(post_id: POST_ID, name: "freestyle")
> PollOption.where(poll_id: poll.id).pluck(:id, :html)
> 
> ```
> 
> If you see `cdn.unicyclist.com` in that HTML, that confirms it.
> 
> ## Fix that one poll
> 
> ```rb
> poll = Poll.find_by(post_id: POST_ID, name: "freestyle")
> 
> PollOption.where(poll_id: poll.id).find_each do |opt|
> new_html = opt.html.gsub("cdn.unicyclist.com", "unicyclist.com")
> opt.update_columns(html: new_html, updated_at: Time.zone.now)
> end
> 
> ```
> 
> Then rebake that post too:
> 
> ```rb
> Post.find(POST_ID).rebake!
> 
> ```
> 
> ## If it works, bulk-fix all poll options
> 
> ```rb
> PollOption.find_each do |opt|
> next unless opt.html&.include?("cdn.unicyclist.com")
> opt.update_columns(
> html: opt.html.gsub("cdn.unicyclist.com", "unicyclist.com"),
> updated_at: Time.zone.now
> )
> end
> 
> ```
> 
> ## Why `posts:remap` didn’t help
> 
> Because that rake task is for **post content** , while your broken image references are probably sitting in the poll option HTML cache instead:
> 
> - [Replace a string in all posts](https://meta.discourse.org/t/replace-a-string-in-all-posts/48729)
> 
> ## Recommendation
> 
> 1. test on **one** broken poll
> 2. confirm the images load
> 3. only then run the bulk fix
> 
> If you want, I can write you a **copy-paste script** where you only replace `POST_ID` and run it safely on a single poll first.

Does that look good to you? I’ll do a backup first obviously, but I prefer to avoid having to restore my forum.

I need to keep all poll results 🙂

Bonus question: should Discourse natively handle those cases?

---

_[View the full topic](https://meta.discourse.org/t/update-urls-inside-a-poll-after-changing-cdn/405198)._
