diff --git a/.env b/.env new file mode 100644 index 0000000..3725d8c --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +NODE_ENV=development +VUE_APP_API_BASE_URL=http://localhost:9090 \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 531c3e6..3afd1f5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -31,7 +31,6 @@ import Vue from 'vue' import Login from "@/views/Login" import router from './router' -import axios from 'axios' import LoadingSpinner from "@/components/LoadingSpinner"; export default Vue.extend({ @@ -62,7 +61,7 @@ export default Vue.extend({ this.loggedin = state; if(state) { router.push("/calendar") - axios.get('http://localhost:9090/profile', { + this.$axios.get('/profile', { headers: { 'Authorization': `Bearer ${window.localStorage.getItem('JWT')}` } @@ -86,7 +85,7 @@ export default Vue.extend({ return; } try{ - const response = await axios.get('http://localhost:9090/profile',{ + const response = await this.$axios.get('/profile',{ headers : { 'Authorization': `Bearer ${window.localStorage.getItem('JWT')}` } diff --git a/src/components/AppointmentModal.vue b/src/components/AppointmentModal.vue index d44d6ef..259e1ba 100644 --- a/src/components/AppointmentModal.vue +++ b/src/components/AppointmentModal.vue @@ -70,8 +70,6 @@ import DatetimePicker from '@/components/DatetimePicker' import Typeahead from '@/components/Typeahead'; import dayjs from 'dayjs' -import axios from 'axios'; -//import axios from 'axios'; export default{ components: { @@ -100,7 +98,7 @@ export default{ this.showModal = true; }, saveClicked: function(){ - axios.post('http://localhost:9090/appointments', { + this.$axios.post('/appointments', { start: dayjs(this.start, 'YYYY-MM-DDTHH:mm').toISOString(), end: dayjs(this.end, 'YYYY-MM-DDTHH:mm').toISOString(), online: this.online, @@ -134,7 +132,7 @@ export default{ this.patient = entry.patient; }, updatePatientSuggestions: function(searchTerm){ - axios.get('http://localhost:9090/patients', { + this.$axios.get('/patients', { params: { name: searchTerm }, diff --git a/src/components/LoginForm.vue b/src/components/LoginForm.vue index ba19b16..e455aa1 100644 --- a/src/components/LoginForm.vue +++ b/src/components/LoginForm.vue @@ -65,7 +65,6 @@ diff --git a/src/main.js b/src/main.js index a19ffa9..d7a0f6c 100644 --- a/src/main.js +++ b/src/main.js @@ -2,7 +2,14 @@ import Vue from 'vue' import App from './App.vue' import router from './router' import '@/assets/styles/index.css' +import axios from "axios"; +const axiosConfig = { + baseUrl: process.env.VUE_APP_API_BASE_URL, + timeout: 30000 +} + +Vue.prototype.$axios = axios.create(axiosConfig) Vue.config.productionTip = false Vue.config.devtools = true Vue.config.performance = true diff --git a/src/views/Calendar.vue b/src/views/Calendar.vue index 1ee0571..6d1e9a9 100644 --- a/src/views/Calendar.vue +++ b/src/views/Calendar.vue @@ -32,7 +32,6 @@ import AppointmentModal from '@/components/AppointmentModal' import dayGridPlugin from '@fullcalendar/daygrid' import timeGridPlugin from "@fullcalendar/timegrid" import interactionPlugin from '@fullcalendar/interaction' -import axios from 'axios'; import { mixin as clickaway } from 'vue-clickaway'; import Popper from "popper.js"; @@ -86,7 +85,7 @@ export default { this.calendarElementClickedLast = false }, deleteAppointment: function(){ - axios.post('http://localhost:9090/appointments/delete',this.selectedEvent.extendedProps.appObj,{ + this.$axios.post('/delete',this.selectedEvent.extendedProps.appObj,{ headers: { 'Authorization': `Bearer ${window.localStorage.getItem('JWT')}` }, @@ -114,7 +113,7 @@ export default { console.log(info) }, getEvents: function(info, successCallback, failureCallback){ - axios.get('http://localhost:9090/appointments', { + this.$axios.get('/appointments', { params: { start: info.startStr, end: info.endStr @@ -152,7 +151,7 @@ export default { }); }, getDisabled: function(info, successCallback, failureCallback){ - axios.get('http://localhost:9090/disabled', { + this.$axios.get('/disabled', { params: { start: info.startStr, end: info.endStr diff --git a/src/views/Disabled.vue b/src/views/Disabled.vue index ec4515c..2d80e3c 100644 --- a/src/views/Disabled.vue +++ b/src/views/Disabled.vue @@ -9,7 +9,6 @@