|
7 | 7 | <script setup> |
8 | 8 | import { onMounted } from 'vue'; |
9 | 9 | import { useUserStore } from '@/stores/user'; |
10 | | -import { useRouter } from 'vue-router'; |
| 10 | +import { useRouter, useRoute } from 'vue-router'; |
11 | 11 | import { callAdminForthApi } from '@/utils'; |
12 | 12 | import { Spinner } from '@/afcl'; |
13 | 13 |
|
14 | 14 | const router = useRouter(); |
15 | 15 | const userStore = useUserStore(); |
| 16 | +const route = useRoute(); |
16 | 17 |
|
17 | 18 | onMounted(async () => { |
18 | 19 | const urlParams = new URLSearchParams(window.location.search); |
19 | 20 | const code = urlParams.get('code'); |
20 | 21 | const state = urlParams.get('state'); |
21 | | - const redirectUri = window.location.origin + '/oauth/callback'; |
| 22 | + |
| 23 | + const baseUrl = route.meta.baseUrl; |
| 24 | + const normalizedBaseUrl = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`; |
| 25 | + const redirectUri = window.location.origin + normalizedBaseUrl + 'oauth/callback'; |
| 26 | + |
22 | 27 | if (code && state && redirectUri) { |
23 | 28 | const encodedCode = encodeURIComponent(code); |
24 | 29 | const encodedState = encodeURIComponent(state); |
25 | | - const encodedRedirectUri = encodeURIComponent(redirectUri); |
26 | 30 | const response = await callAdminForthApi({ |
27 | | - path: `/oauth/callback?code=${encodedCode}&state=${encodedState}&redirect_uri=${encodedRedirectUri}`, |
| 31 | + path: `/oauth/callback?code=${encodedCode}&state=${encodedState}&redirect_uri=${redirectUri}`, |
28 | 32 | method: 'GET', |
29 | 33 | }); |
30 | 34 | if (response.allowedLogin) { |
|
0 commit comments