From a88e404ccfa600f819dbc697ae98b88142e1a2df Mon Sep 17 00:00:00 2001 From: advplyr Date: Mon, 13 Nov 2023 15:22:15 -0600 Subject: [PATCH] Update:Trim trailing slash from server address input --- components/connection/ServerConnectForm.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/connection/ServerConnectForm.vue b/components/connection/ServerConnectForm.vue index 3ed4a223..25061927 100644 --- a/components/connection/ServerConnectForm.vue +++ b/components/connection/ServerConnectForm.vue @@ -334,7 +334,7 @@ export default { */ async oauthExchangeCodeForToken(code, state) { // We need to read the url directly from this.serverConfig.address as the callback which is called via the external browser does not pass us that info - const backendEndpoint = `${this.serverConfig.address}auth/openid/callback?state=${encodeURIComponent(state)}&code=${encodeURIComponent(code)}&code_verifier=${encodeURIComponent(this.oauth.verifier)}` + const backendEndpoint = `${this.serverConfig.address}/auth/openid/callback?state=${encodeURIComponent(state)}&code=${encodeURIComponent(code)}&code_verifier=${encodeURIComponent(this.oauth.verifier)}` try { // We can close the browser at this point (does not work on Android) @@ -674,7 +674,8 @@ export default { // So set the correct protocol for the config const configUrl = new URL(this.serverConfig.address) configUrl.protocol = currentAddressUrl.protocol - this.serverConfig.address = configUrl.toString() + // Remove trailing slash + this.serverConfig.address = configUrl.toString().replace(/\/$/, '') return true }, @@ -819,7 +820,7 @@ export default { this.error = null this.processing = true - const authRes = await this.postRequest(`${this.serverConfig.address}api/authorize`, null, { Authorization: `Bearer ${this.serverConfig.token}` }).catch((error) => { + const authRes = await this.postRequest(`${this.serverConfig.address}/api/authorize`, null, { Authorization: `Bearer ${this.serverConfig.token}` }).catch((error) => { console.error('[ServerConnectForm] Server auth failed', error) const errorMsg = error.message || error this.error = 'Failed to authorize'