# iOS doesn't load CSS sometimes when navigating between subdomains

**URL:** https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740
**Category:** Bug
**Tags:** ios
**Created:** [March 10, 2024, 10:15am UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740 "2024-03-10T10:15:59Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![sok777](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@sok777](https://meta.discourse.org/u/sok777)
#### Post date: [May 21, 2024, 10:44pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/22 "2024-05-21T22:44:03Z")

</div>

I have to admit it’s super hard to reproduce! it’s very inconsistent and we couldn’t find a pattern to it.

---

<div class="post-metadata">

### Author: ![sok777](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@sok777](https://meta.discourse.org/u/sok777)
#### Post date: [June 14, 2024, 2:56pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/23 "2024-06-14T14:56:36Z")

</div>

@pmusaraj quick Q -  
do we think that’s related to discourse as a whole or a specific theme? I couldn’t pin it down to one component yet but thinking whether that may fix it?

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [June 14, 2024, 3:03pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/24 "2024-06-14T15:03:03Z")

</div>

I think it’s not a specific theme or component, it likely has to do with Discourse as a whole. I reproduced it earlier this week on a Discourse site that had pretty much no components installed.

---

<div class="post-metadata">

### Author: ![sok777](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@sok777](https://meta.discourse.org/u/sok777)
#### Post date: [June 14, 2024, 3:33pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/25 "2024-06-14T15:33:33Z")

</div>

Thanks for sharing! Frustrating because the UX is terrible because of it and users have to reload the page or go back. Just trying to be proactive about a workaround

---

<div class="post-metadata">

### Author: ![Architect](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/architect/32/520575_2.png) [@Architect](https://meta.discourse.org/u/Architect)
#### Post date: [June 21, 2024, 2:42pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/26 "2024-06-21T14:42:26Z")

</div>

This is happening with the new discourse discover sub-domain (safari desktop):

 ![Screen Shot 2024-06-21 at 7.40.22 AM](https://global.discourse-cdn.com/meta/original/4X/e/6/b/e6b4cdeda7f207164babf160b0bab3512d73e839.png)

> [@david](#):
>
> If anyone can find a consistent way to reproduce the issue, that would almost certainly help to get the bug prioritised.

Seems to be random that it happens, not often. Is there anyway to run a diagnosis test when this occurs to uncover problem?

---

<div class="post-metadata">

### Author: ![sok777](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@sok777](https://meta.discourse.org/u/sok777)
#### Post date: [June 21, 2024, 6:13pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/27 "2024-06-21T18:13:25Z")

</div>

Based on our analysis so far, the discourse sub-domain thinks it’s still the host and then any relative asset/link is broken. Meaning, unless you use an absolute path (say [discourse.org/css/main.css](http://discourse.org/css/main.css) instead of /css/main.css) it will work. But it’s a pretty crazy workaround as that would include any icon, image, href, js, css etc.

---

<div class="post-metadata">

### Author: ![Senior\_Avr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/senior_avr/32/210181_2.png) [@Senior\_Avr](https://meta.discourse.org/u/Senior_Avr)
#### Post date: [July 4, 2024, 7:12pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/28 "2024-07-04T19:12:05Z")

</div>

This happens for both Desktop & mobile for Safari only.

- Required page parts (external domain) still appears on Discourse’s log, while they should have being logged on the external domain. Couldn’t debug when it happens ☹
- One workaround (instead of changing all CSS/JS/HREF to absolute path) is to place \<base href=“[https://mydomain.com/](https://mydomain.com/)”\> in the header of all relevant pages (on external domain) 🤐

---

<div class="post-metadata">

### Author: ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)
#### Post date: [July 5, 2024, 2:40pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/29 "2024-07-05T14:40:17Z")

</div>

I have just reported a [related issue](https://meta.discourse.org/t/link-to-external-site-remains-in-forum-context-somehow/315117/2) before being pointed to this, which seems to be related.

We just upgraded to Discourse 3.2 two days ago and since then we are getting reports of a similar issue. Although not CSS related in our case, I think the issue is essentially the same.

After following a link in Discourse to our main website, the browser still thinks it’s on the Forum: the URL in the browser says so (!), and sometimes (some? probably relative) links open in the forum domain instead, with an error saying the forum page doesn’t exist. The reports we have so far are all on iPhone/iPad. I can’t reproduce it at all, but those affected seem to experience it a few times a day. Looking at the Discourse logs, I can confirm that there are several 404 requests to pages that only exist on our main website.

I’m quite baffled at the browser opening one website and showing the URL of another (w/o iframes). Being a Safari bug, I sure hope this is only confined within a top domain, as the security implications otherwise are pretty nasty.

In any case, I think something to keep in mind is that this started happening only after we upgraded to Discourse 3.2, so something changed since 3.1 that is triggering this.

Perhaps a complete shot in the dark, but I wonder if this may be somehow related to PWA apps and how they are handled by Safari? Our main website declares a PWA app – and so does our Discourse forum. Both `standalone` and with `start_url: "/"` (ours sets a unique `id`, but Discourse doesn’t). AFAIK, PWA manifest files don’t specify a particular hostname they operate in, so I assume it sticks to the particular one they are hosted in. In our case, the two PWA’s are in separate subdomains but same domain; in how browsers process that there could have room for messing things up and getting the browser confused. But then again, this is just total guess.

---

<div class="post-metadata">

### Author: ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)
#### Post date: [July 5, 2024, 2:42pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/30 "2024-07-05T14:42:39Z")

</div>

> [@Senior\_Avr](#):
>
> Any ideas for an external link workaround?

If this is from a common link (in our case it’s a navigation icon at the top), perhaps a `target=_blank` (or even `target=_top`?) can serve as a temporary workaround?

---

<div class="post-metadata">

### Author: ![Senior\_Avr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/senior_avr/32/210181_2.png) [@Senior\_Avr](https://meta.discourse.org/u/Senior_Avr)
#### Post date: [July 5, 2024, 4:16pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/31 "2024-07-05T16:16:39Z")

</div>

As for as I recall we tried that as well as replacing HREF with JS:function which did ‘window.open’ and still same result.  
Remember: It **is** fetching the external page - so DNS to this new domain works fine, however, it doesn’t switch to that domain while executing the script and fetching that page’s relative-path resources. So as I said the internal Safari “base” HREF is not updated/switched by the page fetch - which make it load relative to current “base” domain → 404

---

<div class="post-metadata">

### Author: ![hello-smile6](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hello-smile6/32/304628_2.png) [@hello-smile6](https://meta.discourse.org/u/hello-smile6)
#### Post date: [July 5, 2024, 4:55pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/32 "2024-07-05T16:55:41Z")

</div>

Is it possible to load JS or CSS from discourse intentionally?

---

<div class="post-metadata">

### Author: ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)
#### Post date: [July 6, 2024, 3:30pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/33 "2024-07-06T15:30:13Z")

</div>

> [@mentalstring](#):
>
> If this is from a common link (in our case it’s a navigation icon at the top), perhaps a `target=_blank` (or even `target=_top`?) can serve as a temporary workaround?

> [@Senior\_Avr](#):
>
> As for as I recall we tried that as well as replacing HREF with JS:function which did ‘window.open’ and still same result.

I’ve tried the `target=_blank` approach and all reports so far are that the problem is gone. Not prefect, but it’s good to have some temporary workaround until there’s more clarity on this.

---

<div class="post-metadata">

### Author: ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)
#### Post date: [July 13, 2024, 12:21pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/34 "2024-07-13T12:21:32Z")

</div>

FWIW, this doesn’t happen only on user initiated click on a link, but also on a javascript “redirect”.

We use SSO on our forum and set up the `logout redirect` with the URL of the main website. When a user logs out of the forum and Discourse “redirects” them to our main website, this also triggers the issue in Safari. From a look at the console, this is not an actual 302 redirect, so maybe a window.location.

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [July 18, 2024, 2:44pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/35 "2024-07-18T14:44:50Z")

</div>

Thanks for the discussions and debugging here folks.

> [@Senior\_Avr](#):
>
> One workaround (instead of changing all CSS/JS/HREF to absolute path) is to place in the header of all relevant pages (on external domain) 🤐

This workaround is simple enough to try out so I have added it to this site ([meta.discourse.org](http://meta.discourse.org)) via a theme component. If it fixes the issue, it would be quite neat because I suspect it can help Webkit devs debug the underlying problem. (And independently, we can also evaluate adding a `base` tag to Discourse core by default.)

---

<div class="post-metadata">

### Author: ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)
#### Post date: [July 18, 2024, 3:11pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/36 "2024-07-18T15:11:35Z")

</div>

My understanding is that the `base` tag workaround may help when applied on an external site, as the problem seems to happen after leaving a discourse website.

Is the test being done on meta to handle the specific case of links between two different discourse instances? Or, did I get lost somewhere (quite possible! 😅)?

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [July 18, 2024, 3:22pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/37 "2024-07-18T15:22:55Z")

</div>

> [@mentalstring](#):
>
> Is the test being done on meta to handle the specific case of links between two different discourse instances?

Yes, our most common issue has been with links between two discourse instances. I think it’s possible that the `base` tag workaround could also help if used on the source site (and the destination isn’t a Discourse instance). If the underlying issue is that Safari/Webkit are confusing the base URLs (this is not too far from your PWA speculations above), then adding a different base to either site may help break the wrong assumption that is at the root of the issue? Speculation on my part as well, but worth trying it out.

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [July 18, 2024, 3:34pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/38 "2024-07-18T15:34:33Z")

</div>

Does this break the DMs button?  
It didn’t work for me until I disabled themes using [safe mode](https://meta.discourse.org/t/53504?silent=true).

 ![Chat](https://global.discourse-cdn.com/meta/original/4X/8/2/3/8233968d1f9b45dd4d0492c766b69a1d88556f2e.jpeg)

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [July 18, 2024, 3:44pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/39 "2024-07-18T15:44:38Z")

</div>

Good catch, it does indeed seem to break it. I have disabled the component with the `base` tag, temporarily.

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [July 18, 2024, 6:18pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/40 "2024-07-18T18:18:25Z")

</div>

Hello 👋 I don’t know I say new or not but tried out now what’s going on on iPad. I noticed it happens every time after page change with browser navigation or slide gesture. Sometimes happens with other cases too. It really easily reproducible on Meta Branded theme home page. With the search bar buttons.

On the video first time go back with browser navigation. Second time go back with slide gesture. Third time go back with click the logo.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [July 18, 2024, 6:27pm UTC](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740/41 "2024-07-18T18:27:08Z")

</div>

Wow yup, those steps reproduce the issue every time for me on desktop Safari. Nice one @Don 🙌

In text form:

1. Open [meta.discourse.org](http://meta.discourse.org) in Safari

2. Click “Guides”

3. Go back (using button, gesture, keyboard shortcut, whatever)

4. Click “Our Hosting”, which is a link to `discourse.org/pricing`

5. Observe broken page. `window.location` is still `meta.discourse.org`, but the HTML is from `discourse.org/pricing`

[Previous page](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740.md?page=1)

[Next page](https://meta.discourse.org/t/ios-doesnt-load-css-sometimes-when-navigating-between-subdomains/298740.md?page=3)
