Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finwise-miniapp-fe
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ThinhNC
finwise-miniapp-fe
Commits
0a8faa53
Commit
0a8faa53
authored
Aug 19, 2026
by
ThinhNC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(fe/client): sync auth tokens with localStorage and configure dynamic VITE_API_URL
parent
18d622d4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
8 deletions
+17
-8
api-client.ts
src/lib/api-client.ts
+9
-4
login.tsx
src/pages/auth/login.tsx
+5
-1
auth.service.ts
src/services/auth.service.ts
+1
-1
transaction.service.ts
src/services/transaction.service.ts
+1
-1
wallet.service.ts
src/services/wallet.service.ts
+1
-1
No files found.
src/lib/api-client.ts
View file @
0a8faa53
import
axios
from
"axios"
;
import
{
useAuthStore
}
from
"@/stores/auth-store"
;
const
apiBaseUrl
=
import
.
meta
.
env
.
VITE_API_URL
||
"http://localhost:7777/api/v1"
;
// Create an Axios instance
export
const
apiClient
=
axios
.
create
({
baseURL
:
"http://localhost:7777/api/v1"
,
baseURL
:
apiBaseUrl
,
timeout
:
10000
,
withCredentials
:
true
,
headers
:
{
...
...
@@ -13,7 +15,7 @@ export const apiClient = axios.create({
// A separate instance for refreshing tokens to avoid interceptor loops
const
refreshClient
=
axios
.
create
({
baseURL
:
"http://localhost:7777/api/v1"
,
baseURL
:
apiBaseUrl
,
timeout
:
10000
,
withCredentials
:
true
,
headers
:
{
...
...
@@ -80,8 +82,11 @@ apiClient.interceptors.response.use(
isRefreshing
=
true
;
try
{
// Try refreshing the token (cookies will be sent automatically)
const
response
=
await
refreshClient
.
post
(
"/auth/refresh"
,
{});
const
storedRefreshToken
=
useAuthStore
.
getState
().
refreshToken
||
localStorage
.
getItem
(
"refreshToken"
);
// Try refreshing the token (cookies will be sent automatically, body as fallback for mobile webviews)
const
response
=
await
refreshClient
.
post
(
"/auth/refresh"
,
{
refreshToken
:
storedRefreshToken
||
undefined
,
});
if
(
response
.
data
?.
success
)
{
const
newData
=
response
.
data
?.
data
;
...
...
src/pages/auth/login.tsx
View file @
0a8faa53
...
...
@@ -74,7 +74,11 @@ const LoginPage: React.FC = () => {
});
if
(
response
.
success
&&
response
.
data
)
{
updateRememberedEmail
(
values
.
email
,
values
.
rememberMe
);
setAuth
(
response
.
data
.
user
,
""
,
""
);
setAuth
(
response
.
data
.
user
,
response
.
data
.
accessToken
||
""
,
response
.
data
.
refreshToken
||
""
);
openSnackbar
({
type
:
"success"
,
text
:
t
(
"auth.login.success"
),
...
...
src/services/auth.service.ts
View file @
0a8faa53
...
...
@@ -12,7 +12,7 @@ export const authService = {
return
response
.
data
;
},
async
login
(
data
:
LoginRequest
):
Promise
<
ApiResponse
<
{
user
:
User
}
>>
{
async
login
(
data
:
LoginRequest
):
Promise
<
ApiResponse
<
{
user
:
User
;
accessToken
?:
string
;
refreshToken
?:
string
}
>>
{
const
response
=
await
apiClient
.
post
(
"/auth/login"
,
data
);
return
response
.
data
;
},
...
...
src/services/transaction.service.ts
View file @
0a8faa53
...
...
@@ -9,7 +9,7 @@ import {
function
ensureSuccess
<
T
extends
{
success
:
boolean
;
message
?:
string
}
>
(
response
:
T
):
T
{
if
(
!
response
.
success
)
{
throw
new
Error
(
response
.
message
||
"
Yêu cầu quản lý giao dịch thất bại
"
);
throw
new
Error
(
response
.
message
||
"
Transaction request failed
"
);
}
return
response
;
}
...
...
src/services/wallet.service.ts
View file @
0a8faa53
...
...
@@ -10,7 +10,7 @@ import {
function
ensureSuccess
<
T
extends
{
success
:
boolean
;
message
?:
string
}
>
(
response
:
T
):
T
{
if
(
!
response
.
success
)
{
throw
new
Error
(
response
.
message
||
"
Yêu cầu quản lý ví không thành công
"
);
throw
new
Error
(
response
.
message
||
"
Wallet request failed
"
);
}
return
response
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment