Skip to content

Commit e40a364

Browse files
committed
Set the backend service API URL using environment variables
1 parent aaca3d2 commit e40a364

File tree

10 files changed

+302
-254
lines changed

10 files changed

+302
-254
lines changed

.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
NEXT_PUBLIC_BACKEND_SERVICE_PROTOCOL="http"
2+
NEXT_PUBLIC_BACKEND_SERVICE_PORT=4000
3+
NEXT_PUBLIC_BACKEND_SERVICE_HOST="localhost"
4+
NEXT_PUBLIC_BACKEND_API_VERSION="0.0.1"
5+
6+
FRONTEND_SERVICE_PORT=3000
7+
FRONTEND_SERVICE_INTERFACE=0.0.0.0

src/lib/api/actions.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Interacts with the action endpoints
22

3+
import { siteConfig } from "@/site.config";
34
import {
45
Action,
5-
actionToString,
66
defaultAction,
77
isAction,
88
isActionArray,
@@ -21,14 +21,14 @@ export const fetchActionsByCoachingSessionId = async (
2121
var err: string = "";
2222

2323
const data = await axios
24-
.get(`http://localhost:4000/actions`, {
24+
.get(`${siteConfig.env.backendServiceURL}/actions`, {
2525
params: {
2626
coaching_session_id: coachingSessionId,
2727
},
2828
withCredentials: true,
2929
setTimeout: 5000, // 5 seconds before timing out trying to log in with the backend
3030
headers: {
31-
"X-Version": "0.0.1",
31+
"X-Version": siteConfig.env.backendApiVersion,
3232
},
3333
})
3434
.then(function (response: AxiosResponse) {
@@ -85,11 +85,11 @@ export const createAction = async (
8585
var err: string = "";
8686

8787
const data = await axios
88-
.post(`http://localhost:4000/actions`, newActionJson, {
88+
.post(`${siteConfig.env.backendServiceURL}/actions`, newActionJson, {
8989
withCredentials: true,
9090
setTimeout: 5000, // 5 seconds before timing out trying to log in with the backend
9191
headers: {
92-
"X-Version": "0.0.1",
92+
"X-Version": siteConfig.env.backendApiVersion,
9393
"Content-Type": "application/json",
9494
},
9595
})
@@ -141,11 +141,11 @@ export const updateAction = async (
141141
console.debug("newActionJson: " + JSON.stringify(newActionJson));
142142

143143
const data = await axios
144-
.put(`http://localhost:4000/actions/${id}`, newActionJson, {
144+
.put(`${siteConfig.env.backendServiceURL}/actions/${id}`, newActionJson, {
145145
withCredentials: true,
146146
setTimeout: 5000, // 5 seconds before timing out trying to log in with the backend
147147
headers: {
148-
"X-Version": "0.0.1",
148+
"X-Version": siteConfig.env.backendApiVersion,
149149
"Content-Type": "application/json",
150150
},
151151
})
@@ -183,11 +183,11 @@ export const deleteAction = async (id: Id): Promise<Action> => {
183183
var err: string = "";
184184

185185
const data = await axios
186-
.delete(`http://localhost:4000/actions/${id}`, {
186+
.delete(`${siteConfig.env.backendServiceURL}/actions/${id}`, {
187187
withCredentials: true,
188188
setTimeout: 5000, // 5 seconds before timing out trying to log in with the backend
189189
headers: {
190-
"X-Version": "0.0.1",
190+
"X-Version": siteConfig.env.backendApiVersion,
191191
"Content-Type": "application/json",
192192
},
193193
})

0 commit comments

Comments
 (0)