Pass apiUrl through OIDC redirect so SPA has it on return
The apiUrl configured on the Config page was lost when the webview navigated away to localhost and back. Now it's included in the return URL as ?desktop=1&apiUrl=...&token=...
This commit is contained in:
@@ -103,7 +103,10 @@ export async function startLogin(): Promise<void> {
|
||||
|
||||
if (isDesktop) {
|
||||
const apiUrl = getConfig().apiUrl || ''
|
||||
const ret = encodeURIComponent(location.origin + location.pathname.replace(/\/$/, '') + '?desktop=1')
|
||||
const ret = encodeURIComponent(
|
||||
location.origin + location.pathname.replace(/\/$/, '') +
|
||||
'?desktop=1&apiUrl=' + encodeURIComponent(apiUrl)
|
||||
)
|
||||
location.href = `http://127.0.0.1:18901/oidc/start?apiUrl=${encodeURIComponent(apiUrl)}&ret=${ret}`
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ function handleDesktopToken() {
|
||||
const params = new URLSearchParams(location.search)
|
||||
const token = params.get('token')
|
||||
if (token && new URLSearchParams(location.search).has('desktop')) {
|
||||
const apiUrl = getConfig().apiUrl || ''
|
||||
const apiUrl = params.get('apiUrl') || getConfig().apiUrl || ''
|
||||
setConfig({ apiUrl, token, isDesktop: true })
|
||||
initConfig({ apiUrl, token, isDesktop: true })
|
||||
params.delete('token')
|
||||
|
||||
Reference in New Issue
Block a user