Quick demo of using another client for some read operations. Other read operations still cause error when primary region is blocked. HPM proxying for local dev still looks to work ok. Still need to add ability to swap out endpoints in the regional endpoint.

This commit is contained in:
Craig Boger (from Dev Box)
2024-02-02 16:09:54 -08:00
parent 2b4a4d0d61
commit 08a4250986
5 changed files with 217 additions and 4 deletions

View File

@@ -81,6 +81,7 @@ export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => {
export const requestPlugin: Cosmos.Plugin<any> = async (requestContext, diagnosticNode, next) => {
requestContext.endpoint = new URL(configContext.PROXY_PATH, window.location.href).href;
requestContext.headers["x-ms-proxy-target"] = endpoint();
console.log(`Request context: ${JSON.stringify(requestContext)}`);
return next(requestContext);
};
@@ -133,6 +134,7 @@ enum SDKSupportedCapabilities {
let _client: Cosmos.CosmosClient;
export function client(): Cosmos.CosmosClient {
console.log(`Called primary client`);
if (_client) return _client;
let _defaultHeaders: Cosmos.CosmosHeaders = {};