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
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:
1 parent
bb45e8d6ae
commit
83b79fe0da
2 files changed
+27
-30
No files matched your search
@@ -8,7 +8,6 @@ import * as fs from 'node:fs';
|
||||
import * as http from 'node:http';
|
||||
import * as https from 'node:https';
|
||||
import * as path from 'node:path';
|
||||
import { isSpider, getUserAgent } from './spider_detection';
|
||||
|
||||
/**
|
||||
* Manually import and register the Angular app engine manifest.
|
||||
@@ -263,17 +262,17 @@ if (isMainModule(import.meta.url)) {
|
||||
const server = http.createServer();
|
||||
server.on('request', async (req, res) => {
|
||||
try {
|
||||
// ── Spider detection gate ──────────────────────────
|
||||
// Only search engine spiders get full SSR rendering.
|
||||
// Regular users receive the CSR app shell from disk,
|
||||
// enhanced with fresh station config injected at runtime.
|
||||
const userAgent = getUserAgent(req.headers);
|
||||
if (!isSpider(userAgent)) {
|
||||
await serveCsrShell(res);
|
||||
return;
|
||||
}
|
||||
|
||||
// Spider — render full HTML via Angular SSR with live API data
|
||||
// ── SSR rendering for all users ────────────────────
|
||||
// Every user — spiders and regular browsers — gets full
|
||||
// Angular SSR rendering. The SSR engine (main.server.ts)
|
||||
// fetches fresh station config from the API via APP_INITIALIZER
|
||||
// before rendering, so the first paint carries real content,
|
||||
// colors, and assets. No CSR shell flash, no blank gap.
|
||||
//
|
||||
// NOTE: The spider-only SSR gate was removed because serving
|
||||
// a CSR shell (empty <app-root>) to regular browsers caused
|
||||
// a visible blank-to-content transition. The SSR engine is
|
||||
// fast enough to handle regular traffic.
|
||||
await requestHandler(req, res, () => {
|
||||
res.statusCode = 404;
|
||||
res.end('Not Found');
|
||||
|
||||
Reference in new issue
Block a user