Skip to content

Commit 4a3ba42

Browse files
committed
Add configurable URL for user service
1 parent 756d470 commit 4a3ba42

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

apps/frontend/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Replace with the corresponding url, credentials and endpoint
2-
NEXT_PUBLIC_API_URL="http://localhost:8080/"
2+
NEXT_PUBLIC_API_URL="http://localhost:8080/"
3+
NEXT_PUBLIC_USER_SERVICE_URL="http://localhost:3001/"

apps/frontend/src/app/services/user.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const USER_SERVICE_URL = "http://localhost:3001"
1+
const USER_SERVICE_URL = process.env.NEXT_PUBLIC_USER_SERVICE_URL
22

33
type UserResponseData = {
44
"id": string,
@@ -25,7 +25,7 @@ export async function createUser(username: string, email: string, password: stri
2525
username, email, password
2626
}),
2727
})
28-
const res = await fetch(`${USER_SERVICE_URL}/users`, opts)
28+
const res = await fetch(`${USER_SERVICE_URL}users`, opts)
2929

3030
if (!res.ok) {
3131
throw new Error(`User service responded with ${res.status}: ${await res.text()}`)
@@ -39,7 +39,7 @@ export async function loginUser(email: string, password: string): Promise<string
3939
email, password
4040
})
4141
});
42-
const res = await fetch(`${USER_SERVICE_URL}/auth/login`, opts);
42+
const res = await fetch(`${USER_SERVICE_URL}auth/login`, opts);
4343

4444
if (!res.ok) {
4545
throw new Error(`User service responded with ${res.status}: ${await res.text()}`);

0 commit comments

Comments
 (0)