Signed-off-by: TIANHE <TIANHE@GMAIL.COM>
This commit is contained in:
TIANHE
2026-01-14 23:50:31 +08:00
parent 47efb7e024
commit 6011ba4ce3
4 changed files with 71 additions and 15 deletions
+15 -2
View File
@@ -1,5 +1,18 @@
import request from '@/utils/request'
function joinApiBase (path) {
const base = (process.env.VUE_APP_API_BASE_URL || '').trim()
const p = path.startsWith('/') ? path : `/${path}`
if (!base) return p
const b = base.replace(/\/+$/, '')
// Avoid duplicate "/api/api/*" when base is "/api" or ends with "/api"
if (b.endsWith('/api') && p.startsWith('/api/')) {
return b + p.slice('/api'.length)
}
return b + p
}
/**
* Get security configuration (Turnstile, OAuth settings)
*/
@@ -107,12 +120,12 @@ export function changePassword (data) {
* Get Google OAuth URL
*/
export function getGoogleOAuthUrl () {
return `${process.env.VUE_APP_API_BASE_URL || ''}/api/auth/oauth/google`
return joinApiBase('/api/auth/oauth/google')
}
/**
* Get GitHub OAuth URL
*/
export function getGitHubOAuthUrl () {
return `${process.env.VUE_APP_API_BASE_URL || ''}/api/auth/oauth/github`
return joinApiBase('/api/auth/oauth/github')
}
+3 -1
View File
@@ -794,7 +794,9 @@ export default {
if (oauthToken) {
this.oauthProcessing = true
storage.set(ACCESS_TOKEN, oauthToken, 7 * 24 * 60 * 60 * 1000)
// NOTE: storage expire plugin expects an absolute timestamp (ms since epoch),
// not a duration. Use "now + 7 days" to avoid immediate expiration.
storage.set(ACCESS_TOKEN, oauthToken, new Date().getTime() + 7 * 24 * 60 * 60 * 1000)
window.history.replaceState({}, document.title, window.location.pathname + window.location.hash.split('?')[0])
this.$store.dispatch('GetInfo').then(() => {
this.$router.push({ path: '/' })