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",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"serve": "vue-cli-service serve --mode development",
"build": "vue-cli-service build --mode production",
"lint": "vue-cli-service lint"
},
"dependencies": {

View File

@ -11,6 +11,7 @@ import Social from './components/Social.vue'
import Settings from './components/Settings.vue'
import Services from './components/Services.vue';
import Tooltip from './components/Tooltip.vue';
import {SERVER_URL} from "./main.js";
export default {
name: 'App',
@ -23,7 +24,7 @@ export default {
methods: {
fetchStatuses() {
console.log("[App][fetchStatuses] Fetching statuses");
fetch("http://localhost:8080/api/v1/statuses")
fetch(`${SERVER_URL}/api/v1/statuses`)
.then(response => response.json())
.then(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 './index.css'
export const SERVER_URL = process.env.NODE_ENV === 'production' ? '.' : 'http://localhost:8080'
createApp(App).mount('#app')