1
votes

I am serving an app behind nginx proxy, and want to preserve phoenix live reload features. The issue is with:

<iframe src="/phoenix/live_reload/frame" style="display: none;"></iframe>

That is added to the main html. I need to change it to:

<iframe src="/new_url/phoenix/live_reload/frame" style="display: none;"></iframe>

I have checked endpoint, and tried to change like this:

if code_reloading? do
  socket "/new_url/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
  plug Phoenix.LiveReloader
  plug Phoenix.CodeReloader
end

But it doesn't seem to change the iframe url. Then I found livereloader.ex in my deps, which I guess allows to set the url with config.

Can someone show how should I set the url for it? Thanks in advance.

Updated the config/dev.exs, yet doesn't seem to work.As pointed out by @PatNowak,the url seems to set host and port, but not the url.

Last: I believe that setting url, as suggested below, changes the socket url, but not actually the iframe src. I'll remove proxy for now to keep the live reload.

1
Try adding url: "/new_url/phoenix/live_reload/socket" after patterns: [...] in config/dev.exs in the live_reload config line. - Dogbert
Hey@Dogbert, I've added it, but unfortunately it doesn't seem to change the url. - Ilya
Did you restart the server after changing the config? Can you add the updated config to the question? - Dogbert
Yep, restarted the server. But I might be wrong about the url, as pointed out by @PatNowak, the line sets host and port, but not the url. Please have a look at his answer - Ilya
Sidenote: please use code blocks to post the code, not screenshots. It’s a general SO rule, that is clearly stated in ToS. - Aleksei Matiushkin

1 Answers

0
votes

You found a place where config[:url] is set, but you missed a comment in the live_reloader.ex. Please check that line. There's presented how this url should looks like.