External applications were unable to call API endpoints with paths like /rest/api/v1/wsemisdoctofunc because the system was treating these routes as UI routes requiring central authentication, instead of API routes that should bypass central auth.
The authentication configuration and route handlers only supported /api/* patterns but not /rest/api/* patterns. When a request came to /rest/api/v1/wsemisdoctofunc, it was:
- Treated as central auth route: The routing middleware classified it as requiring central authentication
- Missing route handler: No handler existed for
/rest/api/*paths - Cross-origin bypass not working: Since it wasn't classified as an API route, cross-origin bypass didn't apply
Extended the authentication system to support both /api/* and /rest/api/* patterns:
// Added /rest/api/** to API patterns
api: {
patterns: [
"/api/**",
"/rest/api/**" // <- Added this
],
// ... rest of config
},
// Added /rest/api/** to bypass central auth
routing: {
bypassCentralAuth: [
"/api/**",
"/rest/api/**" // <- Added this
],
// ... rest of config
}Created a reusable handleDynamicApiEndpoint function and added a new route handler:
// New handler for /rest/api/* routes
app.all("/rest/api/*", async (c) => {
return await handleDynamicApiEndpoint(c, "/rest/api");
});Added /rest/api/ to the list of paths that bypass the layout middleware:
if (
path.startsWith('/api/') ||
path.startsWith('/rest/api/') || // <- Added this
// ... other conditions
) {
await next();
}Now both path patterns work identically:
/api/auth/accesstoken✅ Bypasses central auth, uses cross-origin bypass/rest/api/v1/wsemisdoctofunc✅ Bypasses central auth, uses cross-origin bypass
External applications can now successfully call endpoints like:
POST /rest/api/v1/wsemisdoctofuncGET /rest/api/v2/someendpoint- Any
/rest/api/*pattern
The system will:
- Skip central authentication
- Apply cross-origin bypass (if configured)
- Use the API's own authentication settings
- Return proper responses without redirects
[Routing] Path: /rest/api/v1/wsemisdoctofunc, Strategy: api
[Routing] Route bypasses central auth: /rest/api/v1/wsemisdoctofunc
[API Auth] Skipping authentication for cross-origin/external request
vs. Previous (Failure):
[Routing] Path: /rest/api/v1/wsemisdoctofunc, Strategy: central
[Routing] Applying central auth for: /rest/api/v1/wsemisdoctofunc
[Auth] Unauthenticated access to protected route: /rest/api/v1/wsemisdoctofunc