File tree Expand file tree Collapse file tree 4 files changed +9
-5
lines changed
Expand file tree Collapse file tree 4 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 11import axios from 'axios' ;
22
33const api = axios . create ( {
4- baseURL : import . meta. env . VITE_API_BASE_URL || 'http://localhost:8081 /api' ,
4+ baseURL : import . meta. env . VITE_API_BASE_URL || '/api' ,
55 headers : {
66 'Content-Type' : 'application/json' ,
77 } ,
@@ -62,7 +62,7 @@ api.interceptors.response.use(
6262 try {
6363 // Quick validation call - if this fails, token is bad
6464 await axios . get (
65- `${ import . meta. env . VITE_API_BASE_URL || 'http://localhost:8081 /api' } /auth/validate` ,
65+ `${ import . meta. env . VITE_API_BASE_URL || '/api' } /auth/validate` ,
6666 { headers : { Authorization : `Bearer ${ token } ` } }
6767 ) ;
6868 // Token is valid - this is a genuine permission error (user lacks role)
Original file line number Diff line number Diff line change 1- const SPRING_API = "http://localhost:8081/api/inventory/disposal-vouchers" ;
1+ const API_BASE = ( import . meta. env . VITE_API_BASE_URL || "/api" ) . replace ( / \/ $ / , "" ) ;
2+ const SPRING_API =
3+ import . meta. env . VITE_INVENTORY_DISPOSAL_API_BASE_URL || `${ API_BASE } /inventory/disposal-vouchers` ;
24
35function getAuthHeaders ( ) {
46 const token = localStorage . getItem ( "token" ) ;
Original file line number Diff line number Diff line change 1+ const API_BASE = ( import . meta. env . VITE_API_BASE_URL || "/api" ) . replace ( / \/ $ / , "" ) ;
12const SPRING_API =
2- import . meta. env . VITE_INVENTORY_API_BASE_URL || "http://localhost:8081/api/ inventory" ;
3+ import . meta. env . VITE_INVENTORY_API_BASE_URL || ` ${ API_BASE } / inventory` ;
34
45// ─── Helper: get auth token ──────────────────────────────
56function getAuthHeaders ( ) {
Original file line number Diff line number Diff line change @@ -43,8 +43,9 @@ export function resolveInventoryImageUrl(imageUrl) {
4343 return imageUrl ;
4444 }
4545
46+ const apiBase = ( import . meta. env . VITE_API_BASE_URL || "/api" ) . replace ( / \/ $ / , "" ) ;
4647 const inventoryApiBase =
47- import . meta. env . VITE_INVENTORY_API_BASE_URL || "http://localhost:8081/api/ inventory" ;
48+ import . meta. env . VITE_INVENTORY_API_BASE_URL || ` ${ apiBase } / inventory` ;
4849 const apiOrigin = inventoryApiBase . replace ( / \/ a p i \/ i n v e n t o r y \/ ? $ / , "" ) ;
4950 return `${ apiOrigin } ${ imageUrl . startsWith ( "/" ) ? "" : "/" } ${ imageUrl } ` ;
5051}
You can’t perform that action at this time.
0 commit comments