From 374445f686e66ea449bf96fba44b27c13a7ec3e1 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Tue, 17 Dec 2024 13:27:08 +0700 Subject: [PATCH] fixing api --- src/api/api.sso.ts | 7 +++++++ src/api/index.ts | 21 +++++++++++++-------- src/app.config.ts | 2 ++ src/views/home.vue | 3 ++- src/views/sso.vue | 3 ++- 5 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 src/api/api.sso.ts diff --git a/src/api/api.sso.ts b/src/api/api.sso.ts new file mode 100644 index 0000000..d790271 --- /dev/null +++ b/src/api/api.sso.ts @@ -0,0 +1,7 @@ +import env from "./index"; +const sso = `${env.API_SSO}`; +// const log = `${env.API_URI}/log`; + +export default { + sso, +}; diff --git a/src/api/index.ts b/src/api/index.ts index 8069fca..e63fa38 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,8 +1,9 @@ /**config api */ -import { ref } from 'vue' +import { ref } from "vue"; -const env = ref(process.env.NODE_ENV || 'development') -export const apiUrlConfig = import.meta.env.VITE_API_URI_CONFIG +const env = ref(process.env.NODE_ENV || "development"); +export const apiUrlConfig = import.meta.env.VITE_API_URI_CONFIG; +export const apiUrlSsoConfig = import.meta.env.VITE_API_SSO; // if (process.env.VUE_APP_TEST) { // env = "test"; // } @@ -10,20 +11,24 @@ export const apiUrlConfig = import.meta.env.VITE_API_URI_CONFIG const config = ref({ development: { // API_URI: "https://localhost:7260/api", - API_URI: 'https://bma-ehr.frappet.synology.me/api/v1', + API_URI: "https://bma-ehr.frappet.synology.me/api/v1", + API_SSO: "https://localhost:3001", }, test: { - API_URI: 'http://localhost:5010/api/v1', + API_URI: "http://localhost:5010/api/v1", }, production: { API_URI: apiUrlConfig, + API_SSO: apiUrlSsoConfig, }, -}) +}); -const API_URI = ref(config.value[env.value].API_URI) +const API_URI = ref(config.value[env.value].API_URI); +const API_SSO = ref(config.value[env.value].API_SSO); export default { env: env.value, config: config.value, API_URI: API_URI.value, -} + API_SSO: API_SSO.value, +}; diff --git a/src/app.config.ts b/src/app.config.ts index 42aca54..6c60bc5 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -2,10 +2,12 @@ /** API ระบบลงเวลา */ import org from "@/api/api.org"; +import sso from "@/api/api.sso"; const API = { /**message */ ...org, + ...sso, }; export default { diff --git a/src/views/home.vue b/src/views/home.vue index 15d3e1f..309fec4 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -4,6 +4,7 @@ import router from "@/router"; import { computed, onMounted, ref } from "vue"; import { useQuasar } from "quasar"; import axios from "axios"; +import config from "@/app.config"; import CustomComponent from "@/components/CustomDialog.vue"; @@ -98,7 +99,7 @@ onMounted(async () => { if (!checkToken && !token.value) { await axios .post( - `${import.meta.env.VITE_API_SSO}/kcauth`, + `${config.API.sso}/kcauth`, {}, { headers: { diff --git a/src/views/sso.vue b/src/views/sso.vue index f3dbbc4..a36934d 100644 --- a/src/views/sso.vue +++ b/src/views/sso.vue @@ -3,6 +3,7 @@ import { ref, onMounted } from "vue"; import { useQuasar } from "quasar"; import axios from "axios"; +import config from "@/app.config"; import { useRouter } from "vue-router"; import { useCounterMixin } from "@/stores/mixin"; @@ -28,7 +29,7 @@ async function onSubmit() { await axios .post( - `${import.meta.env.VITE_API_SSO}/signin`, + `${config.API.sso}/signin`, { username: username.value, password: password.value,