Skip to content

Commit

Permalink
Update:Trim trailing slash from server address input
Browse files Browse the repository at this point in the history
  • Loading branch information
advplyr committed Nov 13, 2023
1 parent a7cbdbf commit a88e404
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions components/connection/ServerConnectForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
},
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit a88e404

Please sign in to comment.