Xtrendence/FileDrop

FileDrop Fails to Load when Reverse Proxied

deamos opened this issue · 4 comments

I set up FileDrop with Docker and used Traefik to act as a Reverse Proxy to https (443). Unfortunately, FileDrop fails to fully load due to a check looking to get the port number:

image

utils.js:20

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'replace')
    at getPort (utils.js:20)
    at getIP (utils.js:13)
    at HTMLDocument.<anonymous> (main.js:40)
getPort @ utils.js:20
getIP @ utils.js:13
(anonymous) @ main.js:40 

If I access FileDrop directly with the unproxied port number, FileDrop loads.

I'll have to rewrite those functions then. I don't even know why I used such a complicated way to go about it, the window.location object has the port, protocol etc. in it. I'll push an update in an hour or two. Thank you for bringing this up! :)

Try replacing those functions with these ones:

function getIP() {
	return window.location.hostname;
}

function getPort() {
	let port = window.location.port;

	if(empty(port)) {
		port = getProtocol() === "https:" ? 443 : 80;
	}

	return port;
}

function getProtocol() {
	return window.location.protocol;
}

I don't have a reverse proxy set up, but just using port 80 or 443 doesn't make it crash anymore, so I think that fixes it, but I'll wait for your confirmation.

Edit: The latest update should fix it. Hopefully.

Update Seemed to get it! Great job on fixing it so quickly.!