Fix dev TrackerHub transport
This commit is contained in:
@@ -142,6 +142,23 @@ app.use(["/api", "/flights"], (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
function normalizeTrackerCookie(cookie) {
|
||||
if (!cookie.startsWith("signal-id=")) return cookie;
|
||||
|
||||
const parts = cookie
|
||||
.split(";")
|
||||
.map((part) => part.trim())
|
||||
.filter(
|
||||
(part) =>
|
||||
part.length > 0 &&
|
||||
!part.toLowerCase().startsWith("domain=") &&
|
||||
!part.toLowerCase().startsWith("path=") &&
|
||||
!part.toLowerCase().startsWith("samesite="),
|
||||
);
|
||||
|
||||
return [...parts, "Path=/tracker/hub", "SameSite=Lax"].join("; ");
|
||||
}
|
||||
|
||||
// --- SignalR TrackerHub proxy ---
|
||||
// Browser-direct localhost → platform.test.aeroflot.ru fails CORS. Keep the
|
||||
// hub same-origin in development and let proxy-helper / gost route the
|
||||
@@ -153,6 +170,16 @@ const trackerProxy = createProxyMiddleware({
|
||||
ws: true,
|
||||
logLevel: "warn",
|
||||
pathRewrite: (path) => `/tracker${path}`,
|
||||
on: {
|
||||
proxyRes(proxyRes) {
|
||||
const setCookie = proxyRes.headers["set-cookie"];
|
||||
if (Array.isArray(setCookie)) {
|
||||
proxyRes.headers["set-cookie"] = setCookie.map(normalizeTrackerCookie);
|
||||
} else if (typeof setCookie === "string") {
|
||||
proxyRes.headers["set-cookie"] = normalizeTrackerCookie(setCookie);
|
||||
}
|
||||
},
|
||||
},
|
||||
...(SYSTEM_PROXY ? { agent: new HttpsProxyAgent(SYSTEM_PROXY) } : {}),
|
||||
});
|
||||
app.use("/tracker", trackerProxy);
|
||||
|
||||
Reference in New Issue
Block a user