@@ -55,7 +55,7 @@ export default function UserSettings({ userId }: { userId: string }) {
55
55
const fileInputRef = useRef < HTMLInputElement > ( null ) ;
56
56
57
57
const { data, error, isLoading, mutate } = useSWR (
58
- `${ userServiceUri } /users/${ userId } ` ,
58
+ `${ userServiceUri ( window . location . hostname ) } /users/${ userId } ` ,
59
59
fetcher
60
60
) ;
61
61
const [ user , setUser ] = useState < User | null > ( null ) ;
@@ -140,14 +140,17 @@ export default function UserSettings({ userId }: { userId: string }) {
140
140
}
141
141
142
142
try {
143
- const response = await fetch ( `${ userServiceUri } /users/${ userId } ` , {
144
- method : "PATCH" ,
145
- headers : {
146
- Authorization : `Bearer ${ token } ` ,
147
- "Content-Type" : "application/json" ,
148
- } ,
149
- body : JSON . stringify ( user ) ,
150
- } ) ;
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
+ ) ;
151
154
if ( ! response . ok ) {
152
155
throw new Error ( "Failed to save changes" ) ;
153
156
} else {
@@ -178,13 +181,16 @@ export default function UserSettings({ userId }: { userId: string }) {
178
181
}
179
182
180
183
try {
181
- const response = await fetch ( `${ userServiceUri } /users/${ userId } ` , {
182
- method : "DELETE" ,
183
- headers : {
184
- Authorization : `Bearer ${ token } ` ,
185
- "Content-Type" : "application/json" ,
186
- } ,
187
- } ) ;
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
+ ) ;
188
194
if ( ! response . ok ) throw new Error ( "Failed to delete account" ) ;
189
195
190
196
console . log ( "Account deleted successfully!" ) ;
@@ -238,7 +244,7 @@ export default function UserSettings({ userId }: { userId: string }) {
238
244
239
245
try {
240
246
const response = await fetch (
241
- `${ userServiceUri } /users/${ userId } /change-password` ,
247
+ `${ userServiceUri ( window . location . hostname ) } /users/${ userId } /change-password` ,
242
248
{
243
249
method : "PATCH" ,
244
250
headers : {
0 commit comments