agrinman / agrinman/tunnelto

Unable to proxy websockets?

Ouverte
#63 3 commentaires 3 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Rust
Étoiles
7.1k
Forks
547
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

I'm trying to use Phoenix LiveView over tunnelto. Everything works just fine without proxy or when using ngrok.
With tunnelto I get:

```
[info] Sent 200 in 2ms
[info] CONNECTED TO Phoenix.LiveView.Socket in 25µs
Transport: :websocket
Serializer: Phoenix.Socket.V2.JSONSerializer
Parameters: %{...}
[debug] LiveView session was misconfigured or the user token is outdated.

1) Ensure your session configuration in your endpoint is in a module attribute:

@session_options [
...
]

2) Change the `plug Plug.Session` to use said attribute:

plug Plug.Session, @session_options

3) Also pass the `@session_options` to your LiveView socket:

socket "/live", Phoenix.LiveView.Socket,
websocket: [connect_info: [session: @session_options]]

4) Ensure the `protect_from_forgery` plug is in your router pipeline:

plug :protect_from_forgery

5) Define the CSRF meta tag inside the `` tag in your layout:

<%= csrf_meta_tag() %>

6) Pass it forward in your app.js:

let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content");
let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}});
```

This happens in all browsers.
Standard HTTP requests are proxies just fine.
tunnelto version is 0.1.18.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.