Skip to content

Commit

Permalink
move api base url to config
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Nov 13, 2023
1 parent 0cbc0f5 commit badb460
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/Frontend/src/components/AuthenticatedAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { computed, ref } from 'vue'
import { useRouter } from 'vue-router'
import { useQuasar, LocalStorage } from 'quasar'
import { apiBaseUrl } from '../helpers/apiHelper'
import { parseToken } from '../helpers/tokenHelper'
const $q = useQuasar()
Expand All @@ -28,7 +29,7 @@ async function logout () {
}
async function changePassword () {
const response = await fetch('/api/v1/UserAccount/ChangePassword', {
const response = await fetch(`${apiBaseUrl}UserAccount/ChangePassword`, {
method: 'POST',
headers: {
Authorization: `Bearer ${token.value}`,
Expand Down
4 changes: 3 additions & 1 deletion src/Frontend/src/components/UserAddForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import { computed, ref } from 'vue'
import { LocalStorage, useQuasar } from 'quasar'
import { apiBaseUrl } from '../helpers/apiHelper'
import { UserAdd } from 'src/models/UserAdd'
const $q = useQuasar()
Expand All @@ -17,7 +19,7 @@ const token = computed(() => {
})
async function create () {
const response = await fetch('/api/v1/UserManagement/', {
const response = await fetch(`${apiBaseUrl}UserManagement/`, {
method: 'POST',
headers: {
Authorization: `Bearer ${token.value}`,
Expand Down
4 changes: 3 additions & 1 deletion src/Frontend/src/components/UserEditForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ref, onMounted, computed } from 'vue'
import type { PropType } from 'vue'
import { LocalStorage, useQuasar } from 'quasar'
import { apiBaseUrl } from '../helpers/apiHelper'
import { User } from 'src/models/User'
import { UserEdit } from 'src/models/UserEdit'
Expand Down Expand Up @@ -35,7 +37,7 @@ const token = computed(() => {
})
async function updateUser () {
const response = await fetch(`/api/v1/UserManagement/${props.user.id}`, {
const response = await fetch(`${apiBaseUrl}UserManagement/${props.user.id}`, {
method: 'PUT',
headers: {
Authorization: `Bearer ${token.value}`,
Expand Down
6 changes: 4 additions & 2 deletions src/Frontend/src/components/UserManagementList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { QTableProps, useQuasar, LocalStorage } from 'quasar'
import { User } from 'src/models/User'
import { apiBaseUrl } from '../helpers/apiHelper'
import DefaultDialog from './DefaultDialog.vue'
import UserEditForm from './UserEditForm.vue'
import UserRoleManagement from './UserRoleManagement.vue'
Expand Down Expand Up @@ -67,7 +69,7 @@ async function getUsers () {
try {
loading.value = true
const response = await fetch('/api/v1/UserManagement', {
const response = await fetch(`${apiBaseUrl}UserManagement`, {
headers: {
Authorization: `Bearer ${token.value}`,
'Content-Type': 'application/json'
Expand Down Expand Up @@ -95,7 +97,7 @@ async function removeRow (row : User) {
cancel: true,
persistent: true
}).onOk(async () => {
const response = await fetch(`/api/v1/UserManagement/${row.id}`, {
const response = await fetch(`${apiBaseUrl}UserManagement/${row.id}`, {
method: 'DELETE',
headers: {
Authorization: `Bearer ${token.value}`,
Expand Down
6 changes: 4 additions & 2 deletions src/Frontend/src/components/UserRoleManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ref, computed } from 'vue'
import type { PropType } from 'vue'
import { LocalStorage, useQuasar } from 'quasar'
import { apiBaseUrl } from '../helpers/apiHelper'
import { User } from 'src/models/User'
const $q = useQuasar()
Expand All @@ -25,7 +27,7 @@ const token = computed(() => {
})
async function addRoleToUser () {
const response = await fetch(`/api/v1/UserManagement/${props.user.id}/Role`, {
const response = await fetch(`${apiBaseUrl}UserManagement/${props.user.id}/Role`, {
method: 'POST',
headers: {
Authorization: `Bearer ${token.value}`,
Expand All @@ -51,7 +53,7 @@ async function addRoleToUser () {
}
async function removeRoleFromUser (roleName : string) {
const response = await fetch(`/api/v1/UserManagement/${props.user.id}/Role`, {
const response = await fetch(`${apiBaseUrl}UserManagement/${props.user.id}/Role`, {
method: 'DELETE',
headers: {
Authorization: `Bearer ${token.value}`,
Expand Down
1 change: 1 addition & 0 deletions src/Frontend/src/helpers/apiHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const apiBaseUrl = process.env.NODE_ENV === 'development' ? '/api/v1/' : '/auth/api/v1/'
4 changes: 3 additions & 1 deletion src/Frontend/src/pages/LoginPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { useQuasar, LocalStorage } from 'quasar'
import { apiBaseUrl } from '../helpers/apiHelper'
const $q = useQuasar()
const Router = useRouter()
Expand All @@ -13,7 +15,7 @@ const password = ref('')
async function login () {
loading.value = true
try {
const response = await fetch('/api/v1/Authentication', {
const response = await fetch(`${apiBaseUrl}Authentication`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
Expand Down

0 comments on commit badb460

Please sign in to comment.