fix: fixed IP fetching for nuxt dev

This commit is contained in:
mrjvs
2026-08-19 16:03:15 +02:00
parent fd4baf7e16
commit 2a91827346
2 changed files with 2 additions and 5 deletions

View File

@@ -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",

View File

@@ -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);