mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
Add E2E tests for internationalization across multiple pages
- Implemented navigation.spec.ts to test language switching and translation of navigation elements. - Created sessions-page.spec.ts to verify translations on the sessions page, including headers, status badges, and date formatting. - Developed settings-page.spec.ts to ensure settings page content is translated and persists across sessions. - Added skills-page.spec.ts to validate translations for skill categories, action buttons, and empty states.
This commit is contained in:
@@ -71,12 +71,65 @@ function writeJson(res: ServerResponse, status: number, body: Record<string, unk
|
||||
res.end(JSON.stringify(body));
|
||||
}
|
||||
|
||||
/**
|
||||
* Public API endpoints that can be accessed from localhost without authentication
|
||||
* These are read-only endpoints used by the dashboard for data fetching
|
||||
*/
|
||||
const LOCALHOST_PUBLIC_PATHS = [
|
||||
'/api/data',
|
||||
'/api/orchestrator/flows',
|
||||
'/api/orchestrator/templates',
|
||||
'/api/orchestrator/executions',
|
||||
'/api/orchestrator/templates/remote',
|
||||
'/api/mcp-config',
|
||||
'/api/ccw/tools',
|
||||
'/api/ccw/installations',
|
||||
'/api/cli/endpoints',
|
||||
'/api/skills',
|
||||
'/api/providers',
|
||||
'/api/litellm-api/providers',
|
||||
'/api/litellm-api/endpoints',
|
||||
'/api/health',
|
||||
];
|
||||
|
||||
/**
|
||||
* Check if a path is a public API endpoint (accessible from localhost without auth)
|
||||
*/
|
||||
function isLocalPublicPath(pathname: string): boolean {
|
||||
// Exact match
|
||||
if (LOCALHOST_PUBLIC_PATHS.includes(pathname)) return true;
|
||||
|
||||
// Prefix match for paths with parameters (e.g., /api/orchestrator/flows/:id)
|
||||
for (const publicPath of LOCALHOST_PUBLIC_PATHS) {
|
||||
if (pathname.startsWith(publicPath + '/') || pathname.startsWith(publicPath.replace(/\/[^/]*$/, '/'))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Special handling for paths with wildcards
|
||||
if (pathname.startsWith('/api/orchestrator/flows/')) return true;
|
||||
if (pathname.startsWith('/api/orchestrator/executions/')) return true;
|
||||
if (pathname.startsWith('/api/orchestrator/templates/')) return true;
|
||||
if (pathname.startsWith('/api/litellm-api/providers/')) return true;
|
||||
if (pathname.startsWith('/api/litellm-api/endpoints/')) return true;
|
||||
if (pathname.startsWith('/api/litellm-api/models/')) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function authMiddleware(ctx: AuthMiddlewareContext): boolean {
|
||||
const { pathname, req, res, tokenManager, secretKey, unauthenticatedPaths } = ctx;
|
||||
|
||||
if (!pathname.startsWith('/api/')) return true;
|
||||
if (unauthenticatedPaths?.has(pathname)) return true;
|
||||
|
||||
// Allow localhost requests to public API endpoints without authentication
|
||||
// This enables the Vite dev server (localhost:5173) to proxy API requests
|
||||
if (isLocalhostRequest(req) && isLocalPublicPath(pathname)) {
|
||||
(req as http.IncomingMessage & { authenticated?: boolean }).authenticated = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
const token = extractAuthToken(req);
|
||||
if (!token) {
|
||||
writeJson(res, 401, { error: 'Unauthorized' });
|
||||
|
||||
Reference in New Issue
Block a user