You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been wondering what would be the best way to protect the API endpoints in my server folder which are not related to the authentication? I want my API endpoints to be protected that only authorized users could access them - and also their email address must be present in the JWT - so I can use it to query the database with it later.
I came up with a custom middleware in the server folder like this:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've been wondering what would be the best way to protect the API endpoints in my server folder which are not related to the authentication? I want my API endpoints to be protected that only authorized users could access them - and also their email address must be present in the JWT - so I can use it to query the database with it later.
I came up with a custom
middleware
in theserver
folder like this:Is this considered a best practice? Or did I completely miss something from the docs?
Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions