test: disable rate limiting in testing

This commit is contained in:
Nicolas Meienberger 2026-03-13 23:03:19 +01:00
parent 7473c29948
commit b298524663
3 changed files with 17 additions and 13 deletions

View file

@ -52,18 +52,16 @@ export const createApp = () => {
app.use(honoLogger()); app.use(honoLogger());
} }
if (!config.disableRateLimiting) { app.use(
app.use( rateLimiter({
rateLimiter({ windowMs: 60 * 5 * 1000,
windowMs: 60 * 5 * 1000, limit: 1000,
limit: 1000, keyGenerator: (c) => c.req.header("x-forwarded-for") ?? "",
keyGenerator: (c) => c.req.header("x-forwarded-for") ?? "", skip: () => {
skip: () => { return config.disableRateLimiting;
return config.__prod__ === false; },
}, }),
}), );
);
}
app.use( app.use(
bodyLimit({ bodyLimit({

View file

@ -55,7 +55,7 @@ const envSchema = z
.filter(Boolean) .filter(Boolean)
.concat(s.BASE_URL) ?? [s.BASE_URL], .concat(s.BASE_URL) ?? [s.BASE_URL],
trustProxy: s.TRUST_PROXY === "true", trustProxy: s.TRUST_PROXY === "true",
disableRateLimiting: s.DISABLE_RATE_LIMITING === "true", disableRateLimiting: s.DISABLE_RATE_LIMITING === "true" || s.NODE_ENV === "test",
appSecret: s.APP_SECRET, appSecret: s.APP_SECRET,
baseUrl: s.BASE_URL, baseUrl: s.BASE_URL,
isSecure: s.BASE_URL?.startsWith("https://") ?? false, isSecure: s.BASE_URL?.startsWith("https://") ?? false,

View file

@ -38,9 +38,15 @@ export const auth = betterAuth({
protocol: "auto", protocol: "auto",
}, },
trustedOrigins: config.trustedOrigins, trustedOrigins: config.trustedOrigins,
rateLimit: {
enabled: !config.disableRateLimiting,
},
advanced: { advanced: {
cookiePrefix: "zerobyte", cookiePrefix: "zerobyte",
useSecureCookies: config.isSecure, useSecureCookies: config.isSecure,
ipAddress: {
disableIpTracking: config.disableRateLimiting,
},
}, },
onAPIError: { onAPIError: {
throw: true, throw: true,