ShaneIsrael / fireshare

Self host your media and share with unique links
GNU General Public License v3.0
642 stars 39 forks source link

https:// being omitted from the generated link #250

Closed turnercore closed 2 months ago

turnercore commented 3 months ago

This may not be an issue if you're using a normal domain, but I'm using a .dev domain.

The links the app generates are my.domain.dev/videolinkurlhashstuff, which is probably expected behavior. But a lot of things won't recognize urls with lesser used tlds as links unless you put the http:// or https:// in front of the link.

It would be awesome if there was a setting to enable the copied link to include the http:// or https:// before the domain to avoid this behavior.

Amazing app by the way!

ShaneIsrael commented 3 months ago

@turnercore This is good to know, thank you for bringing it up. I'll try to get a fix out for this as soon as I can.

ShaneIsrael commented 3 months ago

Hmm. In my testing, there doesn't seem to be an issue.

If I have my settings like such. image

The generated links when I click any of the "link share" buttons show up like this.

https://my.domain.dev/w/adba5e61c991b4bbe11dbc5c56ee1c89

which includes the 'https'.

Maybe I'm misunderstanding the problem?

turnercore commented 3 months ago

Ahh, I originally set the "sharable link domain" without the https:// because the ENV variable says not to put it in so I thought it would be the same. Are the links generated when the videos are added to the database? Now I've changed the shareable link domain to include the https:// but all links are still not using the https:// when generated (even for newly uploaded videos as I just tested). Not sure what's going on.

I'm using the unraid container, the ENV domain environment is excluding the https:// and the sharable link used to exclude it, but adding it later isn't changing the links being generated.

turnercore commented 3 months ago

As an update to this, I changed the name to something completely different, saved, and changed it back with the https:// and it is now adding it. Very odd. It seems like it works, I'd probably update it to always include https:// unless http:// was in front of that string in the sharable link domain, defaulting to the domain env variable, if I get time to dig into the code maybe I'll do a pull request with that small change. Thanks for checking it out!

Arlind-dev commented 3 months ago

Yeah, I had the same problem, but I fixed it like this:

  1. Adding the ENV for my domain without HTTP/HTTPS (Restart needed after changing)
  2. Adding HTTPS in the Shareable Link Domain in the WebGui (Restart or waiting 5 minutes)

This might be a little unrelated, but I think it fits here too:

In the docker-compose.yml file in the repository, the ENV DOMAIN has double quotes, but putting down your domain in double quotes breaks OpenGraph. Here's what happens if you use DOMAIN="domain.tld" instead of DOMAIN=domain.tld

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" href="/favicon.ico">
    <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
    <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
    <meta name="msapplication-TileColor" content="#da532c">
    <meta name="theme-color" content="#ffffff">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="theme-color" content="#000000">
    <meta name="description" content="Self-host your media and share with unique links.">
    <link rel="apple-touch-icon" href="/logo192.png">
    <link rel="manifest" href="/manifest.json">
    <meta property="og:type" content="video" data-react-helmet="true">
    <meta property="og:url" content="https://&#34;domain.tld&#34;/#/w/4e361ede2ada8dc27002866d73c7b369" data-react-helmet="true">
    <meta property="og:image" content="https://&#34;domain.tld&#34;/_content/derived/4e361ede2ada8dc27002866d73c7b369/poster.jpg" data-react-helmet="true">
    <meta property="og:video" content="https://&#34;domain.tld&#34;/_content/video/4e361ede2ada8dc27002866d73c7b369.mp4" data-react-helmet="true">
    <meta property="og:video:secure_url" content="https://&#34;domain.tld&#34;/_content/video/4e361ede2ada8dc27002866d73c7b369.mp4" data-react-helmet="true">
    <meta property="og:site_name" content="Fireshare" data-react-helmet="true">
    <meta property="og:title" content="2024-04-01 CS2 Crash" data-react-helmet="true">
    <meta property="og:video:width" content="1920" data-react-helmet="true">
    <meta property="og:video:height" content="1080" data-react-helmet="true">
    <link itemprop="thumbnailUrl" href="https://&#34;domain.tld&#34;/_content/derived/4e361ede2ada8dc27002866d73c7b369/poster.jpg">
    <title>2024-04-01 CS2 Crash</title>
</head>

<body>
    <script>
        window.location.href = "/#/w/4e361ede2ada8dc27002866d73c7b369" + window.location.search;
    </script>
</body>

</html>

The double quotes get replaced with &#34; instead of deleting them.

ShaneIsrael commented 3 months ago

As an update to this, I changed the name to something completely different, saved, and changed it back with the https:// and it is now adding it. Very odd. It seems like it works, I'd probably update it to always include https:// unless http:// was in front of that string in the sharable link domain, defaulting to the domain env variable, if I get time to dig into the code maybe I'll do a pull request with that small change. Thanks for checking it out!

Any changes you make to settings will take a couple minutes to apply and show up. So if you change the shareable link domain and then immediately try a link its going to use the old settings. Wait like 5 minutes and then try and it should be using the new settings.

These links are generated on the fly and not saved to the database. So if you change the shareable link domain, your old videos will give you a link using the newly updated domain.

ShaneIsrael commented 3 months ago

I'm using the unraid container, the ENV domain environment is excluding the https:// and the sharable link used to exclude it, but adding it later isn't changing the links being generated.

The ENV domain variable is different from the shareable link domain. The env variable needs to NOT have the https:// since its injected into the metadata so that opengraph works across apps/sites where you share your videos. So you are using that correctly but that env variable is not used at all in generating your links.

Fireshare's frontend generates the link based off the domain the site is running at. Shareable Link domain is simply a way to override that.

For example, maybe you have 2 different domains pointing to fireshare. A private domain that you only access and a public domain that everyone else accesses. You could set the sharebale link domain to the public domains address so that anytime you or anyone copies a link while visiting from your private domain, they get links generated with the public domain instead.

ShaneIsrael commented 3 months ago

Yeah, I had the same problem, but I fixed it like this:

1. Adding the ENV for my domain without HTTP/HTTPS (Restart needed after changing)

2. Adding HTTPS in the Shareable Link Domain in the WebGui (Restart or waiting 5 minutes)

(the reboots might've been unnecessary)

This might be a little unrelated, but I think it fits here too, in the docker-compose.yml file in the repository:

The ENV DOMAIN has double quotes, but putting down your domain in double quotes breaks OpenGraph. Here's what happens if you use DOMAIN="domain.tld" instead of DOMAIN=domain.tld The double quotes get replaced with &#34; instead of deleting them.

Ah yes, definitely don't add quotes around the ENV domain variable. That is my bad. I'll update the docker-compose file to reflect that.