Skip to content

Commit 10e98e4

Browse files
committed
Merge branch 'release/latest' into main
2 parents a927a2c + fd11864 commit 10e98e4

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "root",
33
"private": true,
4-
"version": "2.3.0",
4+
"version": "2.2.1",
55
"workspaces": [
66
"packages/*",
77
"packages/providers/*",

packages/mgt-element/src/mock/MockGraph.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ import { Graph } from '../Graph';
2020
import { chainMiddleware } from '../utils/GraphHelpers';
2121
import { MockProvider } from './MockProvider';
2222

23-
/**
24-
* The base URL for the mock endpoint
25-
*/
26-
const BASE_URL = 'https://proxy.apisandbox.msdn.microsoft.com/svc?url=';
27-
28-
/**
29-
* The base URL for the graph
30-
*/
31-
const ROOT_GRAPH_URL = 'https://graph.microsoft.com/';
32-
3323
/**
3424
* MockGraph Instance
3525
*
@@ -50,7 +40,6 @@ export class MockGraph extends Graph {
5040

5141
super(
5242
Client.initWithMiddleware({
53-
baseUrl: BASE_URL + ROOT_GRAPH_URL,
5443
middleware: chainMiddleware(...middleware)
5544
})
5645
);
@@ -85,12 +74,13 @@ class MockMiddleware implements Middleware {
8574
*/
8675
private _nextMiddleware: Middleware;
8776

77+
private static _baseUrl;
78+
8879
// tslint:disable-next-line: completed-docs
8980
public async execute(context: Context): Promise<void> {
9081
try {
91-
const url = context.request as string;
92-
const baseLength = BASE_URL.length;
93-
context.request = url.substring(0, baseLength) + escape(url.substring(baseLength));
82+
const baseUrl = await MockMiddleware.getBaseUrl();
83+
context.request = baseUrl + escape(context.request as string);
9484
} catch (error) {
9585
// ignore error
9686
}
@@ -105,4 +95,19 @@ class MockMiddleware implements Middleware {
10595
public setNext(next: Middleware): void {
10696
this._nextMiddleware = next;
10797
}
98+
99+
private static async getBaseUrl() {
100+
if (!this._baseUrl) {
101+
try {
102+
// get the url we should be using from the endpoint service
103+
let response = await fetch('https://cdn.graph.office.net/en-us/graph/api/proxy/endpoint');
104+
this._baseUrl = (await response.json()) + '?url=';
105+
} catch {
106+
// fallback to hardcoded value
107+
this._baseUrl = 'https://proxy.apisandbox.msdn.microsoft.com/svc?url=';
108+
}
109+
}
110+
111+
return this._baseUrl;
112+
}
108113
}

packages/mgt-element/src/utils/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
// THIS FILE IS AUTO GENERATED
99
// ANY CHANGES WILL BE LOST DURING BUILD
1010

11-
export const PACKAGE_VERSION = '2.3.0';
11+
export const PACKAGE_VERSION = '2.2.1';

0 commit comments

Comments
 (0)