diff --git a/.drone.yml b/.drone.yml index 9ed37c6a5..0d601f168 100644 --- a/.drone.yml +++ b/.drone.yml @@ -38,8 +38,8 @@ steps: commands: - yarn --frozen-lockfile - yarn run lint - - "echo '{\"VIKUNJA_API_BASE_URL\": \"/api/v1/\"}' > /drone/src/public/config.json" # Override config - yarn run build + - sed -i 's/http\:\/\/localhost\:8080\/api\/v1/\/api\/v1/g' dist/index.html # Override the default api url used for developing - name: static image: kolaente/zip @@ -112,8 +112,8 @@ steps: commands: - yarn --frozen-lockfile - yarn run lint - - "echo '{\"VIKUNJA_API_BASE_URL\": \"/api/v1/\"}' > /drone/src/public/config.json" # Override config - yarn run build + - sed -i 's/http\:\/\/localhost\:8080\/api\/v1/\/api\/v1/g' dist/index.html # Override the default api url used for developing - name: static image: kolaente/zip diff --git a/Dockerfile b/Dockerfile index 5a7af13ff..bf17d6e88 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,12 @@ WORKDIR /build COPY . ./ -# Override config -RUN echo '{"VIKUNJA_API_BASE_URL": "/api/v1/"}' > /build/public/config.json && \ +RUN \ # Build the frontend yarn install --frozen-lockfile && \ - yarn run build + yarn run build && \ + # Override config + sed -i 's/http\:\/\/localhost\:8080\/api\/v1/\/api\/v1/g' dist/index.html # Stage 2: copy FROM nginx diff --git a/public/config.json b/public/config.json deleted file mode 100644 index a481f397e..000000000 --- a/public/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "VIKUNJA_API_BASE_URL": "http://localhost:8080/api/v1/" -} diff --git a/public/index.html b/public/index.html index 213017464..fa3c15637 100644 --- a/public/index.html +++ b/public/index.html @@ -25,5 +25,13 @@
+ diff --git a/src/http-common/index.js b/src/http-common/index.js index c1dbc92a7..3ef1acc44 100644 --- a/src/http-common/index.js +++ b/src/http-common/index.js @@ -1,6 +1,5 @@ import axios from 'axios' -let config = require('../../public/config.json') export const HTTP = axios.create({ - baseURL: config.VIKUNJA_API_BASE_URL + baseURL: window.API_URL }) diff --git a/src/models/user.js b/src/models/user.js index 494c345ec..b1df455c2 100644 --- a/src/models/user.js +++ b/src/models/user.js @@ -1,5 +1,4 @@ import AbstractModel from './abstractModel' -import config from '../../public/config' export default class UserModel extends AbstractModel { constructor(data) { @@ -19,6 +18,6 @@ export default class UserModel extends AbstractModel { } getAvatarUrl(size = 50) { - return `${config.VIKUNJA_API_BASE_URL}${this.username}/avatar?size=${size}` + return `${window.API_URL}${this.username}/avatar?size=${size}` } } \ No newline at end of file diff --git a/src/services/abstractService.js b/src/services/abstractService.js index bf90c2319..ec2518b01 100644 --- a/src/services/abstractService.js +++ b/src/services/abstractService.js @@ -2,8 +2,6 @@ import axios from 'axios' import {reduce, replace} from 'lodash' import { objectToSnakeCase } from '../helpers/case' -let config = require('../../public/config.json') - export default class AbstractService { ///////////////////////////// @@ -33,7 +31,7 @@ export default class AbstractService { */ constructor(paths) { this.http = axios.create({ - baseURL: config.VIKUNJA_API_BASE_URL, + baseURL: window.API_URL, headers: { 'Content-Type': 'application/json', },