Add MIX_API_URL in env to be ref by webpack

This commit is contained in:
Afiq Hamzah
2024-01-02 16:48:37 +08:00
parent b8db5eb860
commit 5bc3403ce2
3 changed files with 25 additions and 20 deletions
+2
View File
@@ -49,3 +49,5 @@ PUSHER_APP_SECRET=421b61fb5a8ecce477a6
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
# MIX_API_URL=apiujrah.arrahn
MIX_API_URL=api.arrahn
+20 -18
View File
@@ -4,7 +4,7 @@
* building robust, powerful web applications using Vue and Laravel.
*/
import VueApexCharts from 'vue-apexcharts'
import VueApexCharts from 'vue-apexcharts'
import Alpine from 'alpinejs'
import Vue from 'vue'
import Vuex from 'vuex'
@@ -126,31 +126,33 @@ Vue.use(require('vue-pusher'), {
}
});
Vue.prototype.$api1 = 'http://api.arrahn/'
Vue.prototype.$api1 = process.env.MIX_API_URL
Vue.prototype.$username = document.querySelector("meta[name='user_name']").getAttribute('content');
Vue.prototype.$userroles = document.querySelector("meta[name='user_roles']").getAttribute('content');
let initial = 'KB2';
let initialhostname = 'http://api.arrahn/';
let initialhostname = process.env.MIX_API_URL;
let initialtahun = new Date().getFullYear();
const store = new Vuex.Store({
state: {
state: {
$kodcaw: 'KB2',
$hostname: 'http://api.arrahn/',
$hostname: process.env.MIX_API_URL,
$tahun: new Date().getFullYear()
},
plugins: [createPersistedState()],
mutations: {
mutations: {
update$kodcaw: function(state, newKodcaw) {
state.$kodcaw = newKodcaw;
state.$kodcaw = newKodcaw;
},
update$hostname: function(state, newHostname) {
state.$hostname = newHostname;
state.$hostname = newHostname;
},
update$tahun: function(state, newTahun) {
state.$tahun = newTahun;
state.$tahun = newTahun;
},
reset (state) {
state.$kodcaw = initial;
@@ -165,30 +167,30 @@ const store = new Vuex.Store({
Vue.mixin({
computed: {
$kodcaw: {
get: function () {
return store.state.$kodcaw
get: function () {
return store.state.$kodcaw
},
},
$hostname: {
get: function () {
return store.state.$hostname
get: function () {
return store.state.$hostname
},
},
$tahun: {
get: function () {
return store.state.$tahun
get: function () {
return store.state.$tahun
},
}
},
methods:{
setkodcaw: function(newKodcaw) {
setkodcaw: function(newKodcaw) {
// console.log(newKodcaw)
return store.commit('update$kodcaw', newKodcaw);
},
sethostname: function(newHostname) {
sethostname: function(newHostname) {
return store.commit('update$hostname', newHostname);
},
settahun: function(newTahun) {
settahun: function(newTahun) {
return store.commit('update$tahun', newTahun);
},
setLogout: function(){
+3 -2
View File
@@ -90,7 +90,7 @@
case 'JLI':
case 'ARP':
case '020303':{
this.sethostname('http://api.arrahn')
this.sethostname(process.env.MIX_API_URL);
break;
}
case '010621':
@@ -120,7 +120,8 @@
this.sethostname('http://api2.arrahn')
break;
}
default: this.sethostname('http://api.arrahn')
default: this.sethostname(process.env.MIX_API_URL)
break;
}
}