Skip to content

Commit f41f24d

Browse files
committed
Add environment variable to switch backend url
1 parent 1c2b6b0 commit f41f24d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

frontend/nuxt.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export default {
3030
'~/api/index.js'
3131
],
3232

33+
env: {
34+
baseUrl: process.env.NODE_ENV !== 'production' ? '/v1' : 'http://127.0.0.1:8000/v1'
35+
},
36+
3337
/*
3438
** Customize the progress-bar color
3539
*/

frontend/services/api.service.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import axios from 'axios'
2-
const baseURL = 'http://127.0.0.1:8000/v1' // Todo: change URL by development/staging/production.
3-
// const baseURL = '/v1'
42

53
class ApiService {
64
constructor() {
75
this.instance = axios.create({
8-
baseURL
6+
baseURL: process.env.baseUrl
97
})
108
}
119

@@ -24,8 +22,6 @@ class ApiService {
2422
data,
2523
...config
2624
})
27-
// .then(response => response.data)
28-
// .catch(error => error)
2925
}
3026

3127
get(url, config = {}) {

0 commit comments

Comments
 (0)