rishikanthc / Scriberr

Self-hosted AI audio transcription
https://scriberr.app
MIT License
479 stars 18 forks source link

Wrong pocketbase auth token when you restart anew the containers #29

Open Pablo1107 opened 1 month ago

Pablo1107 commented 1 month ago

If you erase all the containers and volumes and start anew, the old token is saved as cookie in the browser and you get this error:

Auth state after loading cookie: true
Auth token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzEyMTYyNTMsImlkIjoiZnRmamcweHBrMm5hZTNkIiwidHlwZSI6ImFkbWluIn0.PBxn6jvwPlENoBD-W8T5beUFztSes2aBkQOofG4jf1c
ClientResponseError 401: The request requires valid admin authorization token to be set.
    at file:///app/node_modules/pocketbase/dist/pocketbase.es.mjs:1:32687
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async configuration (file:///app/build/server/chunks/hooks.server-dE1o57EC.js:94:23)
    at async authentication (file:///app/build/server/chunks/hooks.server-dE1o57EC.js:83:20)
    at async respond (file:///app/build/server/index.js:3859:22)
    at async Array.ssr (file:///app/build/handler.js:1272:3) {
  url: 'http://pocketbase:8080/api/collections?page=1&perPage=500&skipTotal=1',
  status: 401,
  response: {
    code: 401,
    message: 'The request requires valid admin authorization token to be set.',
    data: {}
  },
  isAbort: false,
  originalError: {
    url: 'http://pocketbase:8080/api/collections?page=1&perPage=500&skipTotal=1',
    status: 401,
    data: {
      code: 401,
      message: 'The request requires valid admin authorization token to be set.',
      data: {}
    }
  }
}

The workaround for this is to erase the cookies from the browser and refresh the page.

Maybe this can be fixed by getting a new token if the one saved fails like this.

rishikanthc commented 3 weeks ago

Yeah, I'm aware of this. I'll fix this in the next release. It has actually been a major annoyance during development. Apologies for the bug. I know it's quite inconvenient to do this again and again.