'How to validata user by cookie when send POST request to backend Next.js - Next-Auth?

What I trying to do:

I have a post that users can comment on anything they want by sending to Backend content, userId, postId. Everything working fine BUT: Someone, they know your userId they can use Postman or something same and send to my BE. That's not good!

I see some sites sending cookies and validating in the backend? How can I do that ? By the way, I using Next-auth.

Thank you so much!



Solution 1:[1]

You need to use a backend (server) that stores the different users with their data and uses some sort of authentication to let particular users access to the services, based on their login credentials.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Youzef