riverside

riverside

Howdy everyone!

I have a LiveView site that keeps refreshing when the connection is almost completed within the iOS instagram browser. Navigating around the site still works, but there is a problem with a live component working with a phx-click. This is giving me the idea that the socket is not establishing.

The problem does not occur when using mobile brave or safari. And the site runs smooth on the desktop.

Anyone has general pointers what i should do?
Adjust the http headers?
Adjust the endpoint.ex file?
Or let it be and figure out how to force a message to display a link to redirect the site to be viewed on a phone’s default browser?

And no i have not tried seeing if it happen’s in another social media app’s built in browser. But probably the same thing happens if a web socket isn’t allowed to be fully be established within the app’s internal browser, no?

Pretty lost at this point, any tips and tricks will help. Thanks in advanced.

Showing Posts 1 to 6

jeroenbourgois

jeroenbourgois

Is it online anywhere to see? Have you also updated liveview to the latest version? I remember vaguely having a reloading issue myself, but it was not iOS specific.

riverside

riverside OP

The site is https://garageratz.com
To recreate the problem go to instagram on iOS. Search the thegarageratz and the link is in their bio.

What did you do to fix your reloading problem? If you don’t mind sharing for future reference.

lucaong

lucaong

I can reproduce the issue on Safari for Mac, so it does not seem to be a problem with the Instagram in-app browser only.

One thing I notice is this error:

Refused to connect to wss://garageratz.com/live/websocket?_csrf_token=...
...because it does not appear in the connect-src directive of the Content Security Policy.

I think the problem is that Phoenix LiveView JS fails to connect to the channel due to a CSP violation, and therefore triggers a reload after a timeout. The violation seems to be that your Content-Security-Policy header contains connect-src 'self';. According to MDN:

‘self’ Refers to the origin from which the protected document is being served, including the same URL scheme and port number.

So wss://garageratz.com/... is disallowed, because it uses a different URL scheme than https://garageratz.com.

Note that Chrome is more permissive than Safari when it comes to CSP, which explains why the issue does not occur on Chrome. See this issue for details.

riverside

riverside OP

Thanks for the quick response. I updated the connect-src to be connect-src 'self' wss://garageratz.com, but the problem is still reoccuring in instagram, but on other browsers it is working fine. Sadly i have no way to test it out on a mac…

soup

soup

I am unable to see any issue on Safari 14.2 unfortunately. You could try something like https://www.browserstack.com/ if you don’t have access. I’ve not used it personally though, cant say if its worth the time (and money) or not.

Do you have the correct host, scheme and port set in your config/runtime|prod.exs?

I _dont_ think this would be the actual issue here (you (should?) would see other browsers misbehaving), but you never know with browsers TBH.

Can you see the user agent logs from an instagram request? Might give you a clue as to which webkit/safari build to check into.

Also does is occur when running on your dev machine? (Probably need to make a burner account to point to your local network address to test this in the app.)

lucaong

lucaong

I can confirm that on Safari for Mac now the websocket connects fine, and the page does not reload anymore. I do not have Instagram myself, so I cannot check there, but the CSP issue seems fixed. If the reload still happens on Instagram, it could be a bug specific to that context.

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews