leonardorame

leonardorame

Hi, my LiveView route is this:

  scope "/api", MultiTWeb do                                                                                                                                                                  
    pipe_through [:api, :browser]                                                                                                                                                             
                                                                                                                                                                                              
    live "/:client_uuid/pacientes", EntregaDigitalLive.IndexLive                                                                                                                              
  end

So, going to http://localhost:4003/api/5a1e8e63-e5ce-42f7-ba6c-0de82e2bc587/pacientes works correctly. Then I set up an Apache ProxyPass rule this way:

   RewriteCond %{HTTP:Connection} upgrade [NC]
   RewriteCond %{HTTP:Upgrade} websocket [NC]
   RewriteRule /(.*) "ws://127.0.0.1:4003/$1" [P,L]

   ProxyPass /api http://127.0.0.1:4003/api
   ProxyPassReverse /api http://127.0.0.1:4003/api

This works:

https://example.com/api/5a1e8e63-e5ce-42f7-ba6c-0de82e2bc587/pacientes

Now as this is a multi tennant app I would like to let the user go here:

https://example.com/pacientes

And configure Apache to go to http://127.0.0.1:4003/api/5a1e8e63-e5ce-42f7-ba6c-0de82e2bc587/pacientes:

To do this I just added this ProxyPass directive:

ProxyPass /pacientes http://127.0.0.1:4003/api/5a1e8e63-e5ce-42f7-ba6c-0de82e2bc587/pacientes

Now, if I go to https://example.com/pacientes the page opens correctly, but immediately the websocket crashes giving this error (in Firefox’s developer’s tools → network):

["4","4","lv:phx-GAwVwpiVCAMFmZFx","phx_reply",{"status":"error","response":{"reason":"join crashed"}}]

Also in the Iex console I get:

08:52:26.194 [error] GenServer #PID<0.27095.0> terminating                                     
** (FunctionClauseError) no function clause matching in MultiTWeb.EntregaDigitalLive.IndexLive.mount/3
    (multi_t 0.1.0) lib/multi_t_web/live/entrega_digital_live/index_live.ex:7: MultiTWeb.EntregaDigitalLive.IndexLive.mount(:not_mounted_at_router, %{"_csrf_token" => "VMwaQsqDYHjXnzXxXRP_OO
PM", "live_socket_id" => "users_sessions:zAroyFVodPFvRp1DZkqqW9_K0fz2gbee4CIajR4Vx5Q=", "user_token" => <<204, 10, 232, 200, 85, 104, 116, 241, 111, 70, 157, 67, 102, 74, 170, 91, 223, 202, 
209, 252, 246, 129, 183, 158, 224, 34, 26, 141, 30, 21, 199, 148>>}, #Phoenix.LiveView.Socket<id: "phx-GAwV0UtJEVN__ZHR", endpoint: MultiTWeb.Endpoint, view: MultiTWeb.EntregaDigitalLive.Ind
exLive, parent_pid: nil, root_pid: #PID<0.27095.0>, router: MultiTWeb.Router, assigns: %{flash: %{}, __changed__: %{}, live_action: nil}, transport_pid: #PID<0.27092.0>, ...>)

Why this works:

https://example.com/api/5a1e8e63-e5ce-42f7-ba6c-0de82e2bc587/pacientes

and this not?:

https://example.com/pacientes

Showing Posts 1 to 1

leonardorame

leonardorame OP

I still can’t figure out how to fix this, but I found the websocket’s response has the url parameter exactly as the browser’s url, while it should be the internal app url.

Does anyone know how to force this in Apache?

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

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
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews