/**
 * front connect to keycloak
 */
import Keycloak from "keycloak-js";
// import config from "../app.config";
// import http from "../shared/http";
// import router from "../router";

const initOptions = {
  realm: import.meta.env.VITE_REALM_KEYCLOAK,
  clientId: import.meta.env.VITE_CLIENTID_KEYCLOAK,
  url: import.meta.env.VITE_URL_KEYCLOAK,
  //   realm: "bma-ehr",
  //   clientId: "bma-ehr-vue3",
  //   url: "https://id.frappet.synology.me/",
}; //option keycloak ที่จะ connect

const keycloak = Keycloak(initOptions);

keycloak.onAuthSuccess = () => {}; //เพิ่มlogin สำเร็จจะมาทำฟังก์ชันนี้

await keycloak.init({ onLoad: "check-sso", checkLoginIframe: false }); //ทำการ connect keycloak
export default keycloak;
