karrioapi / karrio

Programmable Shipping API (self-hosted)
https://karrio.io
Apache License 2.0
542 stars 99 forks source link

Unable to login #676

Closed mariushosting closed 1 month ago

mariushosting commented 1 month ago

Using the new version 2024.6 I get the following when I try to connect for the first time:

at async doRender (/app/node_modules/next/dist/server/base-server.js:1377:42)

2024/09/05 09:57PM 50 env=production err={"message":"Request failed with status code 401","name":"AxiosError","stack":"AxiosError: Request failed with status code 401\n at Ae (/app/.next/server/chunks/4084.js:1:552825)\n at IncomingMessage. (/app/.next/server/chunks/4084.js:1:564800)\n at IncomingMessage.emit (node:events:532:35)\n at IncomingMessage.emit (node:domain:488:12)\n at endReadableNT (node:internal/streams/readable:1696:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":["xhr","http"],"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"application/json, text/plain, /","Content-Type":"application/json","User-Agent":"axios/1.6.5","Content-Length":"200","Accept-Encoding":"gzip, compress, deflate, br"},"url":"https://api.karrio.io/api/token","method":"post","data":"{\"redirect\":\"false\",\"email\":\"**admin@example.com**\",\"password\":\"**demo**\",\"csrfToken\":\"de998223f98ac5cc3441fed3ae24673dc26e8ab6add67299fc09dc5a9c49d22b\",\"callbackUrl\":\"http://192.168.1.18:3580/signin?next=/\"}"},"code":"ERR_BAD_REQUEST","status":401} msg=Request failed with status code 401 [auth][error] CredentialsSignin: Read more at https://errors.authjs.dev#credentialssignin

mariushosting commented 1 month ago

I just want to mention that I can connect using the default email and password on the api part but not on the dashboard.

danh91 commented 1 month ago

Hi @mariushosting

I've seen this 🤔. Can you try adding this to your environment variables

AUTH_TRUST_HOST=true

https://github.com/karrioapi/karrio/blob/0b4c7d15569ba95b628dfcf1b8a16c296f1b7dec/docker/dashboard/entrypoint#L5

I will add it to the docs. It look like a requirement for authjs in production.

Please let me know if that solves it.

mariushosting commented 1 month ago

AUTH_TRUST_HOST=true

Unfortunately in a new fresh installation from scratch, with the new Environment variable AUTH_TRUST_HOST=true this not work. Same issue.

I can't replicate any issue with version 2024.2

jacobshilitz commented 1 month ago

I think your url is wrong: "https://api.karrio.io/api/token"

review the deprication of the env vars

https://docs.karrio.io/product/self-hosting/environment/#karrio-dashboard

mariushosting commented 1 month ago

I think your url is wrong: "https://api.karrio.io/api/token"

is not set by me this standard url. Also does not work on localhost too. Can't replicate any issues with previous version 2024.2.

danh91 commented 1 month ago

Nice catch @jacobshilitz ,

Did you update the environment variables to the new NEXT_ appended formats like this https://github.com/karrioapi/karrio/blob/main/apps/dashboard/.env.sample

mariushosting commented 1 month ago

@danh91 @jacobshilitz let me check the new envs. Brb.

mariushosting commented 1 month ago

New env variable fix the issue Thank you for support guys!