@@ -24,6 +24,7 @@ import LoadingScreen from "@/components/common/loading-screen";
24
24
import { useAuth } from "@/app/auth/auth-context" ;
25
25
import { cn } from "@/lib/utils" ;
26
26
import { User , UserSchema } from "@/lib/schemas/user-schema" ;
27
+ import { userServiceUri } from "@/lib/api-uri" ;
27
28
28
29
const fetcher = async ( url : string ) : Promise < User > => {
29
30
// Retrieve the JWT token from localStorage
@@ -54,7 +55,7 @@ export default function UserSettings({ userId }: { userId: string }) {
54
55
const fileInputRef = useRef < HTMLInputElement > ( null ) ;
55
56
56
57
const { data, error, isLoading, mutate } = useSWR (
57
- `http://localhost:3001 /users/${ userId } ` ,
58
+ `${ userServiceUri ( window . location . hostname ) } /users/${ userId } ` ,
58
59
fetcher
59
60
) ;
60
61
const [ user , setUser ] = useState < User | null > ( null ) ;
@@ -139,14 +140,17 @@ export default function UserSettings({ userId }: { userId: string }) {
139
140
}
140
141
141
142
try {
142
- const response = await fetch ( `http://localhost:3001/users/${ userId } ` , {
143
- method : "PATCH" ,
144
- headers : {
145
- Authorization : `Bearer ${ token } ` ,
146
- "Content-Type" : "application/json" ,
147
- } ,
148
- body : JSON . stringify ( user ) ,
149
- } ) ;
143
+ const response = await fetch (
144
+ `${ userServiceUri ( window . location . hostname ) } /users/${ userId } ` ,
145
+ {
146
+ method : "PATCH" ,
147
+ headers : {
148
+ Authorization : `Bearer ${ token } ` ,
149
+ "Content-Type" : "application/json" ,
150
+ } ,
151
+ body : JSON . stringify ( user ) ,
152
+ }
153
+ ) ;
150
154
if ( ! response . ok ) {
151
155
throw new Error ( "Failed to save changes" ) ;
152
156
} else {
@@ -177,13 +181,16 @@ export default function UserSettings({ userId }: { userId: string }) {
177
181
}
178
182
179
183
try {
180
- const response = await fetch ( `http://localhost:3001/users/${ userId } ` , {
181
- method : "DELETE" ,
182
- headers : {
183
- Authorization : `Bearer ${ token } ` ,
184
- "Content-Type" : "application/json" ,
185
- } ,
186
- } ) ;
184
+ const response = await fetch (
185
+ `${ userServiceUri ( window . location . hostname ) } /users/${ userId } ` ,
186
+ {
187
+ method : "DELETE" ,
188
+ headers : {
189
+ Authorization : `Bearer ${ token } ` ,
190
+ "Content-Type" : "application/json" ,
191
+ } ,
192
+ }
193
+ ) ;
187
194
if ( ! response . ok ) throw new Error ( "Failed to delete account" ) ;
188
195
189
196
console . log ( "Account deleted successfully!" ) ;
@@ -237,7 +244,7 @@ export default function UserSettings({ userId }: { userId: string }) {
237
244
238
245
try {
239
246
const response = await fetch (
240
- `http://localhost:3001 /users/${ userId } /change-password` ,
247
+ `${ userServiceUri ( window . location . hostname ) } /users/${ userId } /change-password` ,
241
248
{
242
249
method : "PATCH" ,
243
250
headers : {
0 commit comments