Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make socket location relative to location snapdrop client was served from #288

Merged
merged 2 commits into from
Jun 4, 2021

Conversation

deftdawg
Copy link
Contributor

@deftdawg deftdawg commented Apr 7, 2021

This change makes snapdrop client look for its web socket relative to where the client page was served from, this makes it so the client can be proxied from URLs other than /. It's needed so that the client can be proxied by home assistant (which exposes the container under a path and /server does not work to find the socket).

Adds location.pathname to the socket location, this is needed to make snapdrop proxiable which allows it to be used as Home Assistant Addon.
…sistant

Update Snapdrop client to be proxy friendly.
@deftdawg
Copy link
Contributor Author

deftdawg commented Apr 7, 2021

Currently the snapdrop home assistant addon uses this sed hack in a Dockerfile to work around the problem:

RUN sed -i "s#const url = protocol + '://' + location.host + '/server' + webrtc;#const url = protocol + '://' + location.host + location.pathname + '/server' + webrtc;#" /app/snapdrop/client/scripts/network.js

https://github.com/deftdawg/homeassistant-addons/blob/ded5bf4fefb303cb139fc26f11c79cacaa561388/snapdrop/Dockerfile#L8

Merging this pull would eliminate the need for that.

@RobinLinus RobinLinus merged commit 0ba427c into SnapDrop:master Jun 4, 2021
kiprasmel added a commit to kiprasmel/snapdrop that referenced this pull request Feb 26, 2024
simple solution:
snapdrop.net/    -> room by IP
snapdrop.net/foo -> room foo

invalidates a previously faulty PR:
SnapDrop#288

and provides an alternative: specify the `snapdrop_mount`
if you app is deployed on a different URL than `/`.
kiprasmel added a commit to kiprasmel/snapdrop that referenced this pull request Feb 26, 2024
simple solution:
snapdrop.net/       -> room by IP
snapdrop.net/foo -> room foo, no matter what IP

invalidates a previously faulty PR:
SnapDrop#288

and provides an alternative: specify the `snapdrop_mount` if you app is
deployed on a different URL than `/`. it's not a "hack" to substitute
the path via a command, like the home assistant guys used to do [1] --
it's normal, because you're doing a non-standard deployment. i just
simplified how it'd need to be done now, while for everyone else, the
easy room switching becomes available.

[1] deftdawg/homeassistant-addons@29f99c1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants