mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-08-23 09:07:40 -05:00
fix: fixed IP fetching for nuxt dev
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"license": "AGPL-3.0-only",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node --enable-source-maps .output/server/index.mjs",
|
||||
"start": "node --env-file=.env --enable-source-maps .output/server/index.mjs",
|
||||
"build": "nuxt build",
|
||||
"prepare": "nuxt prepare",
|
||||
"dev": "nuxt dev",
|
||||
|
||||
@@ -39,10 +39,7 @@ export function createRatelimitBucket(ops: RatelimitBucketOptions) {
|
||||
|
||||
export async function enforceRatelimit(event: H3Event, bucket: RateLimiterAbstract): Promise<void> {
|
||||
const config = useRuntimeConfig();
|
||||
const ip = getRequestIP(event, { xForwardedFor: !!config.trustProxy });
|
||||
if (!ip) {
|
||||
throw new Error('Could not get IP for request');
|
||||
}
|
||||
const ip = getRequestIP(event, { xForwardedFor: !!config.trustProxy }) ?? '127.0.0.1'; // nuxt dev returns undefined
|
||||
|
||||
try {
|
||||
await bucket.consume(ip, 1);
|
||||
|
||||
Reference in New Issue
Block a user