A view in my rails application subscribes to a turbo stream channel with <%= turbo_stream_from session["_csrf_token"] %>
. (I use the csrf token as channel name because the stream is meant to be per session.)
In my controller, there is an action which triggers Turbo::StreamsChannel.broadcast_replace_to session["_csrf_token"], partial: "devise/registrations/creating", target: "registration_new_full_page"
. That action replaces the registration form with a loading view before redirecting, given the registration was successful.
In my local development environment, which I access with http://127.0.0.1:3000, everything works just fine. When loading the registration page, the logs show Turbo::StreamsChannel is streaming from TrJhUDOIuzZEKUER3tuC6qsNRsKovL6XEI63bKSuXrk
which is what I’d expect.
Unfortunately, after deploying to fly that exact log line is not shown any more. The broadcasted update is not received and nothing happens. Also, the HTML of the registration page in the browser shows <turbo-cable-stream-source channel="Turbo::StreamsChannel" signed-stream-name="..." connected=""></turbo-cable-stream-source>
for the local development environment, but on fly-deployed environment, that same line is missing connected=""
.
My nginx config contains this:
map $http_host $rails {
myapp.com myapp-rails.flycast;
myapp-staging.com myapp-rails-staging.flycast;
}
...
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_read_timeout 120;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_pass http://$rails;
}
and I don’t see any messages in the browser console that do not appear in the local development environment.
What am I missing here? Any idea what I could be doing wrong?