Me preguntaba si alguien me podría ayudar. Estoy haciendo un programa que se conecta al websocket de pterodactyl pero cada vez que intento conectarme me da un 403 - Prohibido. He estado investigando este error durante algunas horas y parece que no puedo encontrar una solución. Estoy usando NodeJS v17.
Aquí está el código:
const embed = require('../../Configs/embed.json'); let PterodactylUser = require('../../Structures/Panel/PterodactylUser.js'); const SQL = require('../../Structures/Panel/SQL/SQL.js'); const mainConfig = require('../../Configs/config.json'); const WebSocket = require("ws"); module.exports = { name: 'Output', description: 'Sends live console output for the selected server!', category: 'Servers', enabled: true, options: [ { name: "start", type: "SUB_COMMAND", description: "Starts sending console output for the server.", options: [ { name: "id", type: "STRING", description: "The ID of the server to link!", required: true }, { name: "channel", type: "CHANNEL", channelTypes: ["GUILD_TEXT", "GUILD_NEWS"], description: "The channel to link if not set uses current channel!" } ] } ], needsAPIKey: true, async execute(client, Discord, mainConfig, interaction, args) { const user = interaction.user || interaction.author; const channel = args.getChannel('channel') ? args.getChannel('channel') : interaction.channel; const serverId = args.getString('id'); const mysql = new SQL(); let apiKey = await mysql.getApiKey(user.id, interaction.guild.id); let res = await new PterodactylUser(apiKey).getWebsocket(serverId); const { socket, token } = res.data; const ws = new WebSocket(socket); } }Tuve un problema similar causado por configuraciones de acceso al panel mal configuradas. Debe editar /etc/pterodactyl/config.yml
Citando al creador de la biblioteca PteroJS de mi problema :
El origen de la solicitud de websocket no está en la lista blanca. Si tiene acceso a Wings para el nodo que está utilizando, configure
allowed_originsen "config.yml" para esto:
allowed_origins: - "*"De lo contrario, comuníquese con el administrador de su panel al respecto.