H3 · H30006
Use request IP utilities instead of raw IP headers
Request-sensitive H3 handlers should not trust client-controlled forwarding headers directly.
Run this rule
pnpm vite-doctor . --rules h3/request/prefer-get-request-ip
Why it matters
Reading x-forwarded-for directly trusts raw proxy input and may return a spoofed or comma-separated value instead of the client address. On H3 v2, srvx's trustProxy option decides which proxies may set the client address, and getRequestIP(event) and event.req.ip read the result.
Recommended fix
Use getRequestIP(event) and configure trusted proxies centrally instead of reading IP headers directly.
Useful links
Example
Use getRequestIP
Before
export default defineEventHandler((event) => {
return rateLimit(event.req.headers.get('x-forwarded-for'))
})
After
// serve(app, { trustProxy: "loopback" })
export default defineEventHandler((event) => {
return rateLimit(getRequestIP(event))
})