sinamics / ztnet

ZTNET - ZeroTier Web UI for Private Controllers with Multiuser and Organization Support.
https://ztnet.network
GNU General Public License v3.0
558 stars 58 forks source link

[Support]: I'm using npm and i get this error how to fix this ? (Error: APIError: Invalid API Key (get_controller_networks) #558

Closed gbtech-org closed 1 month ago

gbtech-org commented 1 month ago

📝 Inquiry

image

🔖 Version

v0.7.0

🔧 Deployment Type

💻 Operating System

None

🌐 Browser

Chrome

📚 Any Other Information That May Be Helpful

No response

sinamics commented 1 month ago

you can try something like this: ( not tested )

 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header x-ztnet-auth $http_x_ztnet_auth;

In ztnet you can see all the logged in devices and the associated ip address, hence the X-Forwarded-For

gbtech-org commented 1 month ago

it doesn't work with the solution you have provided I also tried to make it with cloudflare tunnel but the same unable to create network

sinamics commented 1 month ago

are you sure the api key you use is correct? Can you provide some code or information on how you add the x-ztnet-key header ?

sinamics commented 1 month ago

ah, sorry, i belived this was related to the api endpoints. Your issue is about the controller connection.

Are you using the default docker-compose layout? Have you changed any setting in the admin => controller page ?

gbtech-org commented 1 month ago

no i don't change anything on admin controller

gbtech-org commented 1 month ago

image

gbtech-org commented 1 month ago

here are the logs i get from docker compose :

`ztnet               | n [APIError]:  APIError:  APIError: Invalid API Key (get_controller_status) (network_create)
ztnet               |     at Object.R (/app/.next/server/chunks/8108.js:1:4632)
ztnet               |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
ztnet               |     at async u (/app/.next/server/chunks/5354.js:52:24619)
ztnet               |     at async /app/.next/server/chunks/5354.js:11:13047
ztnet               |     at async resolveMiddleware (file:///app/node_modules/@trpc/server/dist/index.mjs:420:30)
ztnet               |     at async callRecursive (file:///app/node_modules/@trpc/server/dist/index.mjs:456:32)
ztnet               |     at async callRecursive (file:///app/node_modules/@trpc/server/dist/index.mjs:456:32)
ztnet               |     at async callRecursive (file:///app/node_modules/@trpc/server/dist/index.mjs:456:32)
ztnet               |     at async resolve (file:///app/node_modules/@trpc/server/dist/index.mjs:486:24)
ztnet               |     at async inputToProcedureCall (file:///app/node_modules/@trpc/server/dist/resolveHTTPResponse-cd1a9112.mjs:46:22) {
ztnet               |   status: undefined,
ztnet               |   statusText: undefined,
ztnet               |   cause: undefined
ztnet               | }`
gbtech-org commented 1 month ago

I found the problem so i will close this issue thank you for your support

TBT-TBT commented 1 month ago

What was your problem? I have the same one now.

EDIT: Found it. It was a too small network in the environment of the zerotier container I had

      - ZT_ALLOW_MANAGEMENT_FROM=172.19.0.0/29

(which is only the first 6 ip addresses) and changed it to

      - ZT_ALLOW_MANAGEMENT_FROM=172.19.0.0/24

because ztnet was outside of those 6 ips. Now it works.

It would be nice to post solutions and not just "I found the solution" without details.

gbtech-org commented 1 month ago

I'm happy you find the solution by your self however i was ready to help you with this issue 🙂

TBT-TBT commented 1 month ago

For the next guy it would still help to write what your solution was.

gbtech-org commented 1 month ago

I will do it next time 🙂