Route main SSE traffic to backend

This commit is contained in:
2569718930@qq.com
2026-06-10 12:31:14 +08:00
parent afdfe03174
commit 98026e510a
4 changed files with 75 additions and 3 deletions
@@ -57,6 +57,12 @@ export function runTests() {
modalSource.includes("type=\"textarea\"") === false,
"feedback modal must submit to the feedback API, lock contact to the login email when available, notify the dashboard after success, and attach client/session diagnostics without using invalid textarea input types",
);
assert(
modalSource.includes("formatFeedbackSubmitError") &&
modalSource.includes("looksLikeHtmlDocument") &&
!modalSource.includes("throw new Error(detail || `HTTP ${res.status}`)"),
"feedback modal must not expose raw Cloudflare/HTML error pages to users",
);
assert(
feedbackRouteSource.includes("export async function GET") &&
feedbackRouteSource.includes("method: \"GET\"") &&
@@ -78,6 +78,15 @@ export function runTests() {
assert(nginx.includes("location /api/events"), "Nginx deploy config must route /api/events separately");
assert(nginx.includes("proxy_buffering off"), "Nginx /api/events must disable proxy buffering for SSE");
assert(nginx.includes("proxy_read_timeout 86400s"), "Nginx /api/events must keep SSE connections open");
const frontendServerStart = nginx.indexOf("server_name polyweather.top www.polyweather.top");
const apiServerStart = nginx.indexOf("server_name api.polyweather.top");
const frontendServer = nginx.slice(frontendServerStart, apiServerStart);
assert(
frontendServer.includes("location /api/events") &&
frontendServer.includes("proxy_pass http://127.0.0.1:8000") &&
frontendServer.indexOf("location /api/events") < frontendServer.indexOf("location / {"),
"Nginx frontend host must route /api/events directly to FastAPI before the generic Next.js location",
);
const weatherSources = readRepoFile("src", "data_collection", "weather_sources.py");
assert(weatherSources.includes("_emit_temperature_patch_if_changed"), "collector must centralize temperature patch emission");