Hi youtube.com/@codingwithrobby . How to remove cookies if the user session is expired. In my use case, I want to remove cookies instead of redirecting the user. Need your help, if you can reply. Thanks
@@codingwithrobby - Thanks for the quick response. It works with a server action but I want to validate the user session using middleware and if the session is expired or invalid then the cookie should be deleted but this deletion isn't possible `cookies().delete('Authorization')` in the middleware.
Thanks for this! But I do have a question... Wouldn't be easier to just use the server action to do all the work instead of having it offload the work to the API route? Based on my understanding of server actions, when you submit the form and the server action is called, under the hood there's a POST request being made to a hidden route (the server action). Daisy chaining the reuests like this might introduce more lag since two calls are being made, not to mention you have to account for errors in both methods.
Yeah this tutorial makes no sense. Just a proof that you should not trust any random youtuber for programming knowledge. Soon avg TS code tutorial it's going to be worse than PHP 20 years ago. Type safety is not going to help anyone if people are just going to do stupid things.
bestest tutorial l have come across on Next JS Server Actions and Authentication. Very very easy to understand. thanks to you l now have this well understood 🤩
Very nice :) So if you have time, the next interesting things are 'Forgot password', sending a verification link when a new user registers, to prevent false registrations, and a Google login option :)
fantastic, i managed to follow you throughout the tutorial even if it did take me a while since i had to figure out using drizzle orm but everything was great! will try to implement jwt refresh tokens now
I'm new to server actions and still trying to understand them. Aren't they supposed to be independent of APIs/routes and be able to perform database operations directly within themselves?
I was thinking the same when I saw that part. No need for the fetch call to the api endpoint because you are already on the server, just do a db lookup.
Another useful google output: www.google.com/gasearch?q=nextjs%20server%20actions%20bearer%20token%20authorization&source=sh/x/gs/m2/5#ip=1 even though the results are probably not what you're expecting, it points you in the right direction
Okay so I was building an app and I had implemented a similar JWT authentication just like this, but then decided that I should switch to use NextAuth and now I'm facing issues with the client useSession() method and the server session not syncing. Are you deliberately not using NextAuth? Can this be implemented with Nextauth?
Please, guide me if possible, How to add subscription based payment method that can be customised to any payment solution available all over the world. Take care.
isnt it a bad idea to store the db connection string in an env variable? it can be accessed on the front end. I'm going to watch this video and put it all in the backend and secure it with a public api key and then only allow calls from a certain ip.
I believe that when utilizing server actions, you are essentially making a POST request to an endpoint representing the server action function. In this context, it seems like you are engaging in two fetch operations. I think you can invoke this function within both the signup route and the signup server action. @@codingwithrobby
Great video thanks, but if you have a user and want to display the information or store it somehow in a useContext to be able to use the users information around the app, will I just put cookies().get("Authentication") into a authContext then?