What is pterodactyl panel?
Pterodactyl® is a free, open-source game server management panel built with PHP, React, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to end users.
You can check out the pterodactyl panel in there github.
And this is their api documentation
Issue
I was using the pterodactyl panel api by POST method to create a new user in the panel. I tried it using Postman API platform for testing if it works and it actually worked all good. But when I implemented it in my ReactJS app using fetch function, it returned a very weird response with a 419 error. I am not sure if this type of error is common or not, also I faced this error first time so I have no idea. Would be very grateful if any help is received. 🙂
Code
const currUser = auth.currentUser
const pass = generatePassword()
const userData = {
email: currUser.email,
first_name: currUser.displayName,
last_name:'',
username: currUser.email,
password: pass
};
let reqOpts = {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': api_key,
},
mode: 'no-cors',
body: JSON.stringify(userData)
}
let uri = api_uri+"/api/application/users"
await fetch(uri, reqOpts)
.then(res=>{
if(!res.ok) {
throw new Error('Pterodactyl Panel API resonse is NOT OK nStatus : ' + res.status)
}
return res.json()
})
.catch(err=>{
console.log(err)
alert(err)
})
Error and the response received
screenshot here
I tried to create an user with my app’s authorized user’s details in the pterodactyl panel. I expected a good 200 status response with the details of the created user in the panel.
