fix(pterodactyl): fix failing to connect to the websocket due to a 403 error
All checks were successful
Actions / Lint Code (Ruff) (pull_request) Successful in 6s
Actions / Build Documentation (MkDocs) (pull_request) Successful in 22s

This commit is contained in:
Seaswimmer 2024-02-28 08:14:40 -05:00
parent 53adeb4b80
commit ea84044e73
Signed by: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -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