@@ -80,9 +80,19 @@ define(function (require, exports, module) {
8080 * For desktop apps, this directly uses the configured account URL
8181 */
8282 function getAccountBaseURL ( ) {
83+ if ( location . hostname === 'localhost' || location . hostname === '127.0.0.1' ) {
84+ return '/proxy/accounts' ;
85+ }
8386 return Phoenix . config . account_url . replace ( / \/ $ / , '' ) ; // Remove trailing slash
8487 }
8588
89+ /**
90+ * Get the account website URL for opening browser tabs
91+ */
92+ function _getAccountWebURL ( ) {
93+ return Phoenix . config . account_url ;
94+ }
95+
8696 const ERR_RETRY_LATER = "retry_later" ;
8797 const ERR_INVALID = "invalid" ;
8898
@@ -96,7 +106,7 @@ define(function (require, exports, module) {
96106 * never rejects.
97107 */
98108 async function _resolveAPIKey ( apiKey , validationCode ) {
99- const resolveURL = `${ Phoenix . config . account_url } resolveAppSessionID?appSessionID=${ apiKey } &validationCode=${ validationCode } ` ;
109+ const resolveURL = `${ getAccountBaseURL ( ) } / resolveAppSessionID?appSessionID=${ apiKey } &validationCode=${ validationCode } ` ;
100110 if ( ! navigator . onLine ) {
101111 return { err : ERR_RETRY_LATER } ;
102112 }
@@ -196,7 +206,7 @@ define(function (require, exports, module) {
196206 const authPortURL = _getAutoAuthPortURL ( ) ;
197207 const platformStr = PLATFORM_STRINGS [ Phoenix . platform ] || Phoenix . platform ;
198208 const appName = encodeURIComponent ( `${ Strings . APP_NAME } Desktop on ${ platformStr } ` ) ;
199- const resolveURL = `${ Phoenix . config . account_url } getAppAuthSession?autoAuthPort=${ authPortURL } &appName=${ appName } ` ;
209+ const resolveURL = `${ getAccountBaseURL ( ) } / getAppAuthSession?autoAuthPort=${ authPortURL } &appName=${ appName } ` ;
200210 // {"isSuccess":true,"appSessionID":"a uuid...","validationCode":"SWXP07"}
201211 try {
202212 if ( Phoenix . isTestWindow && fetchFn === fetch ) {
@@ -254,7 +264,7 @@ define(function (require, exports, module) {
254264 }
255265 const { appSessionID, validationCode} = appAuthSession ;
256266 await setAutoVerificationCode ( validationCode ) ;
257- const appSignInURL = `${ Phoenix . config . account_url } authorizeApp?appSessionID=${ appSessionID } ` ;
267+ const appSignInURL = `${ _getAccountWebURL ( ) } authorizeApp?appSessionID=${ appSessionID } ` ;
258268
259269 // Show dialog with validation code
260270 const dialogData = {
@@ -350,7 +360,7 @@ define(function (require, exports, module) {
350360 }
351361
352362 async function signOutAccount ( ) {
353- const resolveURL = `${ Phoenix . config . account_url } logoutSession` ;
363+ const resolveURL = `${ getAccountBaseURL ( ) } / logoutSession` ;
354364 try {
355365 let input = {
356366 appSessionID : userProfile . apiKey
@@ -378,7 +388,7 @@ define(function (require, exports, module) {
378388 Strings . SIGNED_OUT_FAILED_MESSAGE
379389 ) ;
380390 dialog . done ( ( ) => {
381- NativeApp . openURLInDefaultBrowser ( Phoenix . config . account_url + "#advanced" ) ;
391+ NativeApp . openURLInDefaultBrowser ( _getAccountWebURL ( ) + "#advanced" ) ;
382392 } ) ;
383393 Metrics . countEvent ( Metrics . EVENT_TYPE . AUTH , 'logoutFail' , Phoenix . platform ) ;
384394 return ;
@@ -399,7 +409,7 @@ define(function (require, exports, module) {
399409 Strings . SIGNED_OUT_FAILED_MESSAGE
400410 ) ;
401411 dialog . done ( ( ) => {
402- NativeApp . openURLInDefaultBrowser ( Phoenix . config . account_url + "#advanced" ) ;
412+ NativeApp . openURLInDefaultBrowser ( _getAccountWebURL ( ) + "#advanced" ) ;
403413 } ) ;
404414 Metrics . countEvent ( Metrics . EVENT_TYPE . AUTH , 'getAppAuth' , Phoenix . platform ) ;
405415 logger . reportError ( error , "Failed to call logout calling" + resolveURL ) ;
0 commit comments