looks pretty good, but you have some big oopsies on the backend api side: middleware does pretty much nothing (it checks if a Authorization header exists, but you don't check the token so every endpoint could be used with a 'haha-this-is-a-token' Authorization header), for some reason you took a perfect JWT created by supabase, and use it to sign another JWT that you created, you store the token in localStorage (though you have the cookies infra set up perfectly, you should stay with it imo), you throw errors on the server and return 400 (I saw this in a try-catch block somewhere where you correctly threw an error with 403 after doing some checks on the user, but then in the catch block you assigned the same status code, which is not correct, you should make sure the client side errors are handled and throw 500 with minimal info in the console for the others), you check plain text passwords (never ever do that, compare their hashes), validate everything that comes from the frontend. I would do a deep review of the backend if I were you and try to improve it a bit.