fix: harden share link dose operations and token reuse (#298)
* fix: harden share link dose operations and token reuse * fix: restore share dose compatibility and add correlation helper
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
function createCorrelationId(prefix = "fe"): string {
|
||||
const randomPart = Math.random().toString(36).slice(2, 10);
|
||||
return `${prefix}-${Date.now()}-${randomPart}`;
|
||||
}
|
||||
|
||||
export function withCorrelation(init: RequestInit, prefix = "fe"): { correlationId: string; init: RequestInit } {
|
||||
const correlationId = createCorrelationId(prefix);
|
||||
const headers = new Headers(init.headers ?? undefined);
|
||||
headers.set("x-correlation-id", correlationId);
|
||||
|
||||
return {
|
||||
correlationId,
|
||||
init: {
|
||||
...init,
|
||||
headers,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user