Add SERVER_URL constant based on environment

This commit is contained in:
TwinProduction 2021-01-25 22:05:19 -05:00
parent 5755f3a699
commit 2ccd656386
3 changed files with 6 additions and 3 deletions

View File

@ -3,8 +3,8 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve --mode development",
"build": "vue-cli-service build", "build": "vue-cli-service build --mode production",
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {

View File

@ -11,6 +11,7 @@ import Social from './components/Social.vue'
import Settings from './components/Settings.vue' import Settings from './components/Settings.vue'
import Services from './components/Services.vue'; import Services from './components/Services.vue';
import Tooltip from './components/Tooltip.vue'; import Tooltip from './components/Tooltip.vue';
import {SERVER_URL} from "./main.js";
export default { export default {
name: 'App', name: 'App',
@ -23,7 +24,7 @@ export default {
methods: { methods: {
fetchStatuses() { fetchStatuses() {
console.log("[App][fetchStatuses] Fetching statuses"); console.log("[App][fetchStatuses] Fetching statuses");
fetch("http://localhost:8080/api/v1/statuses") fetch(`${SERVER_URL}/api/v1/statuses`)
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
if (JSON.stringify(this.serviceStatuses) !== JSON.stringify(data)) { if (JSON.stringify(this.serviceStatuses) !== JSON.stringify(data)) {

View File

@ -2,4 +2,6 @@ import { createApp } from 'vue'
import App from './App.vue' import App from './App.vue'
import './index.css' import './index.css'
export const SERVER_URL = process.env.NODE_ENV === 'production' ? '.' : 'http://localhost:8080'
createApp(App).mount('#app') createApp(App).mount('#app')