add production url
This commit is contained in:
parent
a1e9ac285a
commit
a2fb11a59b
|
|
@ -1,8 +1,18 @@
|
|||
import axios from 'axios'
|
||||
import { getToken } from './keycloak'
|
||||
|
||||
// Determine API base URL based on environment
|
||||
const getApiBaseUrl = (): string => {
|
||||
// In production, API is proxied through the same domain at /api
|
||||
if (import.meta.env.PROD) {
|
||||
return window.location.origin + '/api'
|
||||
}
|
||||
// In development, use localhost backend
|
||||
return 'http://localhost:5050/api'
|
||||
}
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: 'http://localhost:5050/api'
|
||||
baseURL: getApiBaseUrl()
|
||||
})
|
||||
|
||||
api.interceptors.request.use(
|
||||
|
|
|
|||
|
|
@ -2,10 +2,21 @@ import Keycloak from 'keycloak-js'
|
|||
|
||||
let keycloak: Keycloak | null = null
|
||||
|
||||
// Get base URL from environment or use current origin
|
||||
const getRedirectUri = (): string => {
|
||||
// In production, use the current domain
|
||||
if (import.meta.env.PROD) {
|
||||
return window.location.origin + '/'
|
||||
}
|
||||
// In development, use localhost
|
||||
return 'http://localhost:3030/'
|
||||
}
|
||||
|
||||
export const initKeycloak = async (): Promise<Keycloak> => {
|
||||
console.log('Initializing Keycloak...')
|
||||
|
||||
const clientId = 'dalex-proto'
|
||||
const redirectUri = getRedirectUri()
|
||||
|
||||
keycloak = new Keycloak({
|
||||
url: 'https://terminus.bluelake.cloud', // Remove trailing slash
|
||||
|
|
@ -16,7 +27,8 @@ export const initKeycloak = async (): Promise<Keycloak> => {
|
|||
console.log('Keycloak config:', {
|
||||
url: 'https://terminus.bluelake.cloud',
|
||||
realm: 'dalex-immo-dev',
|
||||
clientId: clientId
|
||||
clientId: clientId,
|
||||
redirectUri: redirectUri
|
||||
})
|
||||
|
||||
try {
|
||||
|
|
@ -24,7 +36,7 @@ export const initKeycloak = async (): Promise<Keycloak> => {
|
|||
onLoad: 'login-required',
|
||||
checkLoginIframe: false,
|
||||
pkceMethod: 'S256', // Using PKCE for public clients
|
||||
redirectUri: 'http://localhost:3030/', // Explicit redirect URI
|
||||
redirectUri: redirectUri, // Use dynamic redirect URI
|
||||
flow: 'standard' // Explicitly use standard (Authorization Code) flow
|
||||
})
|
||||
|
||||
|
|
@ -65,6 +77,6 @@ export const getToken = (): string | undefined => {
|
|||
|
||||
export const logout = (): void => {
|
||||
keycloak?.logout({
|
||||
redirectUri: 'http://localhost:3030/'
|
||||
redirectUri: getRedirectUri()
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
/* eslint-disable */
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare module '*.vue' {
|
||||
import type { DefineComponent } from 'vue'
|
||||
const component: DefineComponent<{}, {}, any>
|
||||
|
|
|
|||
Loading…
Reference in New Issue