#Ratelimiting issue with Nextjs and fastapi

16 messages · Page 1 of 1 (latest)

humble dragon
#

I want to add ratelimiting to my endpoints, and the endpoints that are protected get fetched through serversideprops in nextjs, and because of that it can't get the users ip address, and it gets the ip address of the vps, and my whole application is ratelimited because the server itself has been ratelimited. How can i add endpoint protection?

half nestBOT
#

🔎 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)

dire epoch
#

im not sure exactly abt your environment. but assuming that you host a Next.js instance on serverfull or managed env where the instance lives long, you can use a cookie to store uuid and manage a hash in JS global variable in the server side. it's naive solution. keep in mind it won't work as DoS protection as http headers can be spoofed easily.

#

having Cloudflare Worker in front of the VPS works but won't work for DDoS.

humble dragon
dire epoch
#

usually it’s called throttling

humble dragon
#

im currently using apache

dire epoch
#

Apache? you mean HTTP server, which used to be a popular reverse proxy for Tomcat Java Servelet?

dire epoch
#

wow. yeah, it is. amazing.

humble dragon
dire epoch
#

i mean it’s outdated tech stack. just i remember i used to work with those tech. usually you don’t need it as we can employ Vercel, Cloudflare, Supabase and so on. Cloudflare replaces Nginx with Pingora, which is Rust Tokio reverse proxy

#

you might want to study what reverse proxy is. i would recommend you to play around with Cloudflare Worker, you will get ideas