#Protecting API Route

9 messages · Page 1 of 1 (latest)

vocal shale
#

Hey, im currently having trouble to secure or protecting my api route, my first idea to protect it just like the image, but im realize this is useless, people can open they console web and see the key, what else i can do to make some authorization.

I cant use next-auth because this form is meant to be public from, like guests or not login member perform order

hardy pantherBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

wind wharf
vocal shale
wind wharf
# vocal shale Idk how to explain it, but the goal is to store a some data into my database by ...

when your route is public, you can add a public api key, that the user (client) somehow receives when using your page. This api key can then be verified by your server. Keep in mind: the public api key is shared with the client so it can be published and there can still abuse of your functions.

Some things you might want to consider are ratelimiting by ip. Another thing you might want to think of is by using CORS to only allow requests from a specific origin. That's just a basic protection and you should add an additional layer of security on the network level to prevent unwanted access

hardy pantherBOT
#
✅ Success!

This question has been marked as answered! If you have any other questions, feel free to create another post

Jump to answer
wind wharf
#

happy to help

vocal shale