panel icon indicating copy to clipboard operation
panel copied to clipboard

Use location.origin to set the remote parameter in config

Open SivertGullbergHansen opened this issue 6 months ago • 9 comments

Is there an existing feature request for this?

  • [X] I have searched the existing issues before opening this feature request.

Describe the feature you would like to see.

When you edit a node in the Pterodactyl Panel, the default setting for the remote parameter is HTTP://, even if your panel is using HTTPS://. I want the Pterodactyl Panel to use the correct origin (HTTP or HTTPS) or at least let me choose between HTTP:// and HTTPS:// when configuring the node.

Describe the solution you'd like.

Instead of specifying the remote parameter manually, please use location.origin (you can find more information about it here: https://developer.mozilla.org/en-US/docs/Web/API/Location/origin). This method automatically sets the correct origin based on where the user is accessing the panel from.

Additional context to this request.

Whenever I update my node's setting, it automatically updates the config for the node, which breaks it (because it assigns the remote value to HTTP:// when my panel is hosted at HTTPS://). It causes me to manually ssh into my WM and update the config with the correct protcol.

SivertGullbergHansen avatar Dec 21 '23 13:12 SivertGullbergHansen

if you are talking about the remote field on the admin side, on the node configuration tab that is pulled from the .env value you set when you configured your panel? (Apparently only v2 does that)

QuintenQVD0 avatar Dec 21 '23 13:12 QuintenQVD0

the default setting for the remote parameter is HTTP://

This is not true. It already uses the url that is used for accessing the panel. So if you access the panel via http://panel.example.com the remote will also be this.

v2 will however change that to use the APP_URL instead, for better consistency. (if the pending PR is accepted)

Boy132 avatar Dec 21 '23 13:12 Boy132

if you are talking about the remote field on the admin side, on the node configuration tab that is pulled from the .env value you set when you configured your panel? (Apparently only v2 does that)

I am running Pterodactyl Panel 1.11.5, I was not aware v2 is available?

So if you access the panel via http://panel.example.com the remote will also be this.

I access my panel from HTTPS, so still strange that it does not use this protocol...

Is it possible for me to switch to v2?

SivertGullbergHansen avatar Dec 21 '23 13:12 SivertGullbergHansen

Is it possible for me to switch to v2?

v2 is not available. It's still in development and not production ready.

I access my panel from HTTPS, so still strange that it does not use this protocol...

Is your panel running behind a proxy? If yes that might be the problem. And/ or it's a Laravel bug.

Boy132 avatar Dec 21 '23 13:12 Boy132

Is your panel running behind a proxy? If yes that might be the problem. And/ or it's a Laravel bug.

My panel is accessible through Cloudflare Tunnels, so I would say yes?

SivertGullbergHansen avatar Dec 21 '23 13:12 SivertGullbergHansen

My panel is accessible through Cloudflare Tunnels, so I would say yes?

Yes, I guess that's the problem. Or at least somehow related to the issue.

As a workaround you can edit Line 159 in ./app/Models/Node.php and change route('index') to config('app.url'). Assuming your APP_URL in your .env file is correct it will then use the correct value for the remote field.

Boy132 avatar Dec 21 '23 13:12 Boy132

IF cloudflared is passing the correct headers, then it might be enough for you to just set the TRUSTED_PROXIES value so the headers from cloudflared is trusted.

danny6167 avatar Dec 21 '23 14:12 danny6167

v2 will however change that to use the APP_URL instead, for better consistency.

Will this also mean that you would be able to run under a subfolder easier?

At home I am unable to easily make a subdomain for my local server. So I have to use subfolder, but at the moment the panel is not designed for it...

Miniontoby avatar Feb 17 '24 11:02 Miniontoby

v2 will however change that to use the APP_URL instead, for better consistency.

Will this also mean that you would be able to run under a subfolder easier? [...]

No, v2 will still not support subfolders.

Boy132 avatar Feb 17 '24 14:02 Boy132