Closed louisjoecodes closed 4 months ago
ratelimit.limit
can be called even before getUser
and getBankAccountsCurrencies
I think. Something like:
export async function submitUserMessage(
content: string
): Promise<ClientMessage> {
const ip = headers().get("x-forwarded-for");
const { success } = await ratelimit.limit(ip);
if (!success) {
aiState.update({
...aiState.get(),
messages: [
...aiState.get().messages,
{
id: nanoid(),
role: "assistant",
content:
"Not so fast, tiger. You've reached your message limit. Please wait a minute and try again.",
},
],
});
return {
id: nanoid(),
role: "assistant",
display: (
<BotMessage content="Not so fast, tiger. You've reached your message limit. Please wait a minute and try again." />
),
};
}
// rest of the code
}
Thank you! this is now fixed!
Found a small vulnerability where there are currently no rate limits applied to AI api endpoints.
Proposed change in file:
apps/dashboard/src/actions/ai/chat/index.tsx