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.
https://pterodactyl.io
Other
6.41k stars 1.57k forks source link

API Debugging #3128

Closed Epod closed 3 years ago

Epod commented 3 years ago

Hello,

I am running a fresh install, using all default nginx configs from the documentation. All API calls are directly calling HTTPS, no reverse proxy, cloudflare or anything of the like. These are direct calls to the panel.

When I attempt to create a server using /servers the server returns a 302 with no information on why. For reference, if I specify a invalid API key, I get a 403 as expected.

Other API calls work just fine (list/create users for example).

I believe I might be specifying something incorrectly, but I have no way of debugging what the panel is rejecting with just a 302.

Here is a example curl that would return a 302

curl -X POST -k -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json' -i 'https://gs.xxxxx.com/api/application/servers' --data '{
  "name": "Building",
  "user": 1,
  "egg": 1,
  "docker_image": "quay.io/pterodactyl/core:java",
  "startup": "java -Xms128M -Xmx128M -jar server.jar",
  "environment": {
    "BUNGEE_VERSION": "latest",
    "SERVER_JARFILE": "server.jar"
  },
  "limits": {
    "memory": 128,
    "swap": 0,
    "disk": 512,
    "io": 500,
    "cpu": 100
  },
  "feature_limits": {
    "databases": 5,
    "backups": 1
  },
  "allocation": {
    "default": 17
  }
}'
matthewpi commented 3 years ago

Try adding -H 'Accept: application/json'

Epod commented 3 years ago

Same results

Is there a way to debug using logging or some specific command?

matthewpi commented 3 years ago

Same results

Is there a way to debug using logging or some specific command?

The APP_DEBUG=true and APP_ENV=development environment variables may help you.

That header is what worked for me, I sent a request to the panel on a /api/client/servers/<SERVER>/files/list while the node was offline, without that header it would return a 302 but with it would return a JSON error. I'd expect the same behavior to affect the application api but I could be wrong.

Epod commented 3 years ago

Thank you, it looks like I incorrectly was passing through the Accept header for some reason in this one instance.