fix(ssr): remove spider-only gate — serve full SSR to all users
CI Pipeline / backend-test (pull_request) Successful in 9m46s
CI Pipeline / frontend-test (pull_request) Successful in 23s
CI Pipeline / frontend-build (pull_request) Successful in 30s
CI Pipeline / backend-lint (pull_request) Successful in 8s
CI Pipeline / quality-gate (push) Successful in 2s
CI Pipeline / backend-test (push) Successful in 9m58s
CI Pipeline / frontend-test (push) Successful in 23s
CI Pipeline / frontend-build (push) Successful in 29s
CI Pipeline / backend-lint (push) Successful in 8s
CI Pipeline / quality-gate (pull_request) Successful in 2s

The CSR shell served to regular browsers caused a visible blank-to-content
flash: the browser painted an empty <app-root>, then waited for Angular
to bootstrap and lazy-load the route before any content appeared.

All requests now route through the Angular SSR engine (appEngine.handle()),
which fetches fresh station config from the API via APP_INITIALIZER before
rendering. The first paint carries real content, colors, and assets.
This commit is contained in:
robot committed 2026-08-09 08:13:35 +00:00
1 parent bb45e8d6ae
commit 83b79fe0da
2 files changed
+27 -30

No files matched your search

+16 -18
View File
@@ -33,28 +33,26 @@ vi.mock('./angular-app-engine-manifest.mjs', () => ({
}));
describe('SSR server — server.ts', () => {
it('should export a request handler', async () => {
it('should route all requests through Angular SSR engine (no spider gate)', async () => {
const fs = require('fs');
const content = fs.readFileSync('./server.ts', 'utf-8');
expect(content).toContain('requestHandler(req, res,');
// Should NOT have spider-only SSR gate
expect(content).not.toContain('if (!isSpider(userAgent))');
expect(content).not.toContain('isSpider');
});
it('should still have serveCsrShell as a fallback for when SSR engine fails', async () => {
const fs = require('fs');
const content = fs.readFileSync('./server.ts', 'utf-8');
expect(content).toContain('serveCsrShell');
});
it('should have request handler export', async () => {
const mod = await import('./server');
expect(mod.requestHandler).toBeDefined();
});
it('should have spider detection imports and serveCsrShell', async () => {
const fs = require('fs');
const content = fs.readFileSync('./server.ts', 'utf-8');
expect(content).toContain('isSpider');
expect(content).toContain('getUserAgent');
expect(content).toContain('serveCsrShell');
expect(content).toContain('spider_detection');
});
it('should gate SSR behind spider detection', async () => {
const fs = require('fs');
const content = fs.readFileSync('./server.ts', 'utf-8');
// Verify the spider detection gate exists
expect(content).toContain("if (!isSpider(userAgent))");
expect(content).toContain('serveCsrShell(res)');
});
it('should inject fresh station config as window.__STATION_CONFIG', async () => {
const fs = require('fs');
const content = fs.readFileSync('./server.ts', 'utf-8');