fix: prevent auth logout by sending refresh request without expired access token header

This commit is contained in:
2026-02-07 15:31:10 +01:00
parent 135c23e55e
commit 641793b2c4
2 changed files with 23 additions and 8 deletions

View File

@@ -285,16 +285,24 @@ class DirectusService {
if (!this.refreshToken) return false
try {
const response = await this.post('/auth/refresh', {
refresh_token: this.refreshToken,
mode: 'json'
const response = await fetch(`${this.baseUrl}/auth/refresh`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
refresh_token: this.refreshToken,
mode: 'json'
})
})
if (!response.ok) throw new Error('Refresh failed')
const result = await response.json()
if (response.data) {
if (result.data) {
this.saveTokens(
response.data.access_token,
response.data.refresh_token,
response.data.expires
result.data.access_token,
result.data.refresh_token,
result.data.expires
)
return true
}