Skip to content

Commit 22a6cf7

Browse files
committed
fix: use redirect URI in OAuth HTML page for proxy support
The HTML page that extracts the access token from the URL hash must redirect back through the proxy URI, not hardcoded localhost.
1 parent f6e46dd commit 22a6cf7

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/b2c-tooling-sdk/src/auth/oauth-implicit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface ImplicitOAuthConfig {
4747
* Returns the HTML page served to the browser to extract the access token
4848
* from the URL fragment and redirect it as query parameters.
4949
*/
50-
function getOauth2RedirectHTML(port: number): string {
50+
function getOauth2RedirectHTML(redirectUri: string): string {
5151
return `
5252
<!DOCTYPE html>
5353
<html lang="en">
@@ -58,7 +58,7 @@ function getOauth2RedirectHTML(port: number): string {
5858
<body onload="doReturnFlow()">
5959
<script>
6060
function doReturnFlow() {
61-
document.location = "http://localhost:${port}/?" + window.location.hash.substring(1);
61+
document.location = "${redirectUri}/?" + window.location.hash.substring(1);
6262
}
6363
</script>
6464
</body>
@@ -352,7 +352,7 @@ export class ImplicitOAuthStrategy implements AuthStrategy {
352352
// Serve HTML page to extract token from URL fragment
353353
logger.debug('[Auth] Serving token extraction HTML page');
354354
response.writeHead(200, {'Content-Type': 'text/html'});
355-
response.write(getOauth2RedirectHTML(this.localPort));
355+
response.write(getOauth2RedirectHTML(this.redirectUri));
356356
response.end();
357357
} else if (accessToken) {
358358
const authDuration = Date.now() - startTime;

0 commit comments

Comments
 (0)