docs(hono): clarify CORS middleware must be registered before routes (#3707)

- Add complete example showing app.on() and serve() after CORS setup
- Include important note explaining CORS must come before route registration
- Ensures consistency with middleware section and prevents user confusion
- Critical for proper cross-origin request handling in authentication endpoints
This commit is contained in:
Braden Wong
2025-07-31 00:24:22 -07:00
committed by GitHub
parent 15e0e59f6d
commit 33b0635c4d

View File

@@ -48,8 +48,14 @@ app.use(
}),
);
app.on(["POST", "GET"], "/api/auth/*", (c) => {
return auth.handler(c.req.raw);
});
serve(app);
```
> **Important:** CORS middleware must be registered before your routes. This ensures that cross-origin requests are properly handled before they reach your authentication endpoints.
### Middleware