# Pdf files on same server don't show onebox with subdomain url

**URL:** https://meta.discourse.org/t/pdf-files-on-same-server-dont-show-onebox-with-subdomain-url/100472
**Category:** Support
**Created:** [10월 25, 2018, 4:13오후 UTC](https://meta.discourse.org/t/pdf-files-on-same-server-dont-show-onebox-with-subdomain-url/100472 "2018-10-25T16:13:32Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Rocancourt](https://avatars.discourse-cdn.com/v4/letter/r/7c8e57/32.png) [@Rocancourt](https://meta.discourse.org/u/Rocancourt)
#### Post date: [10월 25, 2018, 4:13오후 UTC](https://meta.discourse.org/t/pdf-files-on-same-server-dont-show-onebox-with-subdomain-url/100472/1 "2018-10-25T16:13:32Z")

</div>

Hi,

Firstly, congratulation for this open source project.

I want make clean display for local pdf files with onebox. I saw that is not to possible with attachment, so i link pdf files from url on same server.

With or without whitelist internal hosts, That work with domains but i don’t see onebox for pdf files from subdomains url (my discourse url is on a subdomain). For my tests, All domains/subdomains redirect on the same server.

 ![discourse](https://global.discourse-cdn.com/meta/original/3X/8/b/8be60412ff36b8debc4bb95422b92357729fe454.png)  
(_On test screen, only domains display onebox_)

I have read some posts about this, but i don’t understand the problem :

> [@Internal URL no longer oneboxing](https://meta.discourse.org/t/internal-url-no-longer-oneboxing/64208):
>
> At some point in the last 2 days internal URLs stopped oneboxing on my instance. I’m up to date with tests-passed as of 1:15 AM EST 6/9/17. There are the errors I’m seeing in the console when a post with an internal URL is loaded. There do not appear to be any related errors in /logs.

[https://meta.discourse.org/t/onebox-domains-whitelist-and-subdomains/40884](https://meta.discourse.org/t/onebox-domains-whitelist-and-subdomains/40884)

How i can fix it ?

Thanks,

PS : Link work for subdomain, i can see pdf file, that’s just display problem for onebox on content.

---

<div class="post-metadata">

### Author: ![Rocancourt](https://avatars.discourse-cdn.com/v4/letter/r/7c8e57/32.png) [@Rocancourt](https://meta.discourse.org/u/Rocancourt)
#### Post date: [10월 25, 2018, 7:16오후 UTC](https://meta.discourse.org/t/pdf-files-on-same-server-dont-show-onebox-with-subdomain-url/100472/2 "2018-10-25T19:16:19Z")

</div>

I have search in the code,

```
 def self.external_onebox(url)
Rails.cache.fetch(onebox_cache_key(url), expires_in: 1.day) do
  fd = FinalDestination.new(url, ignore_redirects: ignore_redirects, ignore_hostnames: blacklisted_domains, force_get_hosts: force_get_hosts)
  uri = fd.resolve
  return blank_onebox if uri.blank? || blacklisted_domains.map { |hostname| uri.hostname.match?(hostname) }.any?

  options = {
    cache: {},
    max_width: 695,
    sanitize_config: Sanitize::Config::DISCOURSE_ONEBOX
  }

  options[:cookie] = fd.cookie if fd.cookie

  if Rails.env.development? && SiteSetting.port.to_i > 0
    Onebox.options = { allowed_ports: [80, 443, SiteSetting.port.to_i] }
  end

  r = Onebox.preview(uri.to_s, options)

  { onebox: r.to_s, preview: r&.placeholder_html.to_s }
end

```

I think the problem is here, no mention for the whitelist ?

` return blank_onebox if uri.blank? || blacklisted_domains.map { |hostname| uri.hostname.match?(hostname) }.any?`

> **[pdf.pdf](https://www.pdf995.com/samples/pdf.pdf)**
>
> 423.82 KB

This link don’t work too, https can be is the problem ?

Thanks,

---

<div class="post-metadata">

### Author: ![Rocancourt](https://avatars.discourse-cdn.com/v4/letter/r/7c8e57/32.png) [@Rocancourt](https://meta.discourse.org/u/Rocancourt)
#### Post date: [10월 26, 2018, 6:06오후 UTC](https://meta.discourse.org/t/pdf-files-on-same-server-dont-show-onebox-with-subdomain-url/100472/3 "2018-10-26T18:06:05Z")

</div>

Finally, the subdomain without https is the problem.

My post is resolved 🙂

---

<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: [10월 26, 2018, 6:35오후 UTC](https://meta.discourse.org/t/pdf-files-on-same-server-dont-show-onebox-with-subdomain-url/100472/4 "2018-10-26T18:35:23Z")

</div>


