Skip to content

Commit db9089b

Browse files
Theodor N. EngøyTheodor N. Engøy
authored andcommitted
examples: add explicit JSON body size limit
1 parent e6b02fb commit db9089b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

examples/shared/src/authServer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ export function setupAuthServer(options: SetupAuthServerOptions): void {
167167
authApp.get('/.well-known/oauth-authorization-server', cors(), toNodeHandler(oAuthDiscoveryMetadata(auth)));
168168

169169
// Body parsers for non-better-auth routes (like /sign-in)
170-
authApp.use(express.json());
171-
authApp.use(express.urlencoded({ extended: true }));
170+
const maxBodyBytes = 100 * 1024; // Make the default explicit to avoid accidental large-body DoS.
171+
authApp.use(express.json({ limit: maxBodyBytes }));
172+
authApp.use(express.urlencoded({ extended: true, limit: maxBodyBytes }));
172173

173174
// Auto-login page that creates a real better-auth session
174175
// This simulates a user logging in and approving the OAuth request

0 commit comments

Comments
 (0)