Automated Preview URLs (#601)

This commit is contained in:
Steve Faulkner
2021-04-02 12:24:01 -05:00
committed by GitHub
parent ba24eabe7c
commit bd9bdad78a
10 changed files with 595 additions and 6 deletions

View File

@@ -32,7 +32,7 @@ export const tokenProvider = async (requestInfo: RequestInfo) => {
};
export const requestPlugin: Cosmos.Plugin<any> = async (requestContext, next) => {
requestContext.endpoint = configContext.PROXY_PATH;
requestContext.endpoint = new URL(configContext.PROXY_PATH, window.location.href).href;
requestContext.headers["x-ms-proxy-target"] = endpoint();
return next(requestContext);
};

View File

@@ -56,7 +56,7 @@ export function sendMessage(data: any): void {
signature: "pcIframe",
data: data,
},
portalChildWindow.document.referrer
portalChildWindow.document.referrer || "*"
);
}
}
@@ -71,7 +71,7 @@ export function sendReadyMessage(): void {
kind: "ready",
data: "ready",
},
portalChildWindow.document.referrer
portalChildWindow.document.referrer || "*"
);
}
}

View File

@@ -2,7 +2,7 @@
exports[`requestPlugin Emulator builds a url for emulator proxy via webpack 1`] = `
Object {
"endpoint": "/proxy",
"endpoint": "http://localhost/proxy",
"headers": Object {
"x-ms-proxy-target": "http://localhost",
},
@@ -12,7 +12,7 @@ Object {
exports[`requestPlugin Hosted builds a proxy URL in development 1`] = `
Object {
"endpoint": "/proxy",
"endpoint": "http://localhost/proxy",
"headers": Object {
"x-ms-proxy-target": "baz",
},