From ea84044e7363c3dd75f412628eff9aec3c03183c Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Wed, 28 Feb 2024 08:14:40 -0500 Subject: [PATCH] fix(pterodactyl): fix failing to connect to the websocket due to a 403 error --- pterodactyl/pterodactyl.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pterodactyl/pterodactyl.py b/pterodactyl/pterodactyl.py index 6d757ce..ba68760 100644 --- a/pterodactyl/pterodactyl.py +++ b/pterodactyl/pterodactyl.py @@ -29,6 +29,11 @@ class Pterodactyl(commands.Cog): base_url = await self.config.base_url() api_key = await self.config.api_key() server_id = await self.config.server_id() + + extra_headers = { + "Origin": base_url + } + try: client = PterodactylClient(base_url, api_key).client websocket_credentials = client.servers.get_websocket(server_id) @@ -40,7 +45,7 @@ class Pterodactyl(commands.Cog): self.logger.error(f'Failed to retrieve Pterodactyl websocket: {e}') return - async with websockets.connect(websocket_credentials['data']['socket']) as websocket: + async with websockets.connect(websocket_credentials['data']['socket'], extra_headers=extra_headers) as websocket: self.logger.debug("WebSocket connection established") # Send authentication token