Compare commits

..

No commits in common. "5b8e22d9d10019a79d6ca0388a4302c40ded63c2" and "49ae9728f3aa71ff14e16b6411b3493bb8bd0e6f" have entirely different histories.

8 changed files with 12 additions and 52 deletions

View File

@ -48,12 +48,8 @@ export const authApi = {
},
me: async (): Promise<UserResponse> => {
const response = await apiClient.get<UserResponse>('/api/v1/auth/me')
console.log('🔍 Raw /me API response:', response)
console.log('🔍 Response data:', response.data)
console.log('🔍 Response data type:', typeof response.data)
console.log('🔍 Response data keys:', response.data ? Object.keys(response.data) : 'no keys')
return response.data
const { data } = await apiClient.get<UserResponse>('/api/v1/auth/me')
return data
},
changePassword: async (

View File

@ -3,11 +3,7 @@ import axios from 'axios'
// Get API base URL from environment variable or use default
// The .env file should contain: VITE_API_URL=http://127.0.0.1:8000
// Alternatively, Vite proxy can be used (configured in vite.config.ts) by setting VITE_API_URL to empty string
// When VITE_API_URL is empty/undefined, use relative path to work with HTTPS proxy
const envApiUrl = import.meta.env.VITE_API_URL
const API_BASE_URL = envApiUrl && envApiUrl.trim() !== ''
? envApiUrl
: '' // Use relative path when empty - works with proxy and HTTPS
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://127.0.0.1:8000'
export const apiClient = axios.create({
baseURL: API_BASE_URL,

View File

@ -27,11 +27,8 @@ export const jobsApi = {
},
streamJobProgress: (jobId: string): EventSource => {
// EventSource needs absolute URL - use VITE_API_URL or construct from current origin
const envApiUrl = import.meta.env.VITE_API_URL
const baseURL = envApiUrl && envApiUrl.trim() !== ''
? envApiUrl
: window.location.origin // Use current origin when empty - works with proxy and HTTPS
// EventSource needs absolute URL - use VITE_API_URL or fallback to direct backend URL
const baseURL = import.meta.env.VITE_API_URL || 'http://127.0.0.1:8000'
return new EventSource(`${baseURL}/api/v1/jobs/stream/${jobId}`)
},

View File

@ -70,11 +70,8 @@ export const photosApi = {
},
streamJobProgress: (jobId: string): EventSource => {
// EventSource needs absolute URL - use VITE_API_URL or construct from current origin
const envApiUrl = import.meta.env.VITE_API_URL
const baseURL = envApiUrl && envApiUrl.trim() !== ''
? envApiUrl
: window.location.origin // Use current origin when empty - works with proxy and HTTPS
// EventSource needs absolute URL - use VITE_API_URL or fallback to direct backend URL
const baseURL = import.meta.env.VITE_API_URL || 'http://127.0.0.1:8000'
return new EventSource(`${baseURL}/api/v1/jobs/stream/${jobId}`)
},

View File

@ -108,18 +108,12 @@ export const videosApi = {
},
getThumbnailUrl: (videoId: number): string => {
const envApiUrl = import.meta.env.VITE_API_URL
const baseURL = envApiUrl && envApiUrl.trim() !== ''
? envApiUrl
: '' // Use relative path when empty - works with proxy and HTTPS
const baseURL = import.meta.env.VITE_API_URL || 'http://127.0.0.1:8000'
return `${baseURL}/api/v1/videos/${videoId}/thumbnail`
},
getVideoUrl: (videoId: number): string => {
const envApiUrl = import.meta.env.VITE_API_URL
const baseURL = envApiUrl && envApiUrl.trim() !== ''
? envApiUrl
: '' // Use relative path when empty - works with proxy and HTTPS
const baseURL = import.meta.env.VITE_API_URL || 'http://127.0.0.1:8000'
return `${baseURL}/api/v1/videos/${videoId}/video`
},
}

View File

@ -38,12 +38,6 @@ export function AuthProvider({ children }: { children: ReactNode }) {
authApi
.me()
.then((user) => {
console.log('🔍 Auth /me response:', {
username: user.username,
is_admin: user.is_admin,
role: user.role,
permissions: user.permissions
})
setAuthState({
isAuthenticated: true,
username: user.username,
@ -87,12 +81,6 @@ export function AuthProvider({ children }: { children: ReactNode }) {
localStorage.setItem('access_token', tokens.access_token)
localStorage.setItem('refresh_token', tokens.refresh_token)
const user = await authApi.me()
console.log('🔍 Login /me response:', {
username: user.username,
is_admin: user.is_admin,
role: user.role,
permissions: user.permissions
})
const passwordChangeRequired = tokens.password_change_required || false
setAuthState({
isAuthenticated: true,
@ -145,13 +133,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
if (authState.isAdmin) {
return true
}
const hasPerm = Boolean(authState.permissions[featureKey])
console.log(`🔍 hasPermission(${featureKey}):`, {
isAdmin: authState.isAdmin,
hasPerm,
permissions: authState.permissions
})
return hasPerm
return Boolean(authState.permissions[featureKey])
},
[authState.isAdmin, authState.permissions]
)

View File

@ -604,8 +604,7 @@ export default function Identify() {
const preloadImages = () => {
const preloadUrls: string[] = []
// Use relative path when baseURL is empty (works with proxy and HTTPS)
const baseUrl = apiClient.defaults.baseURL || ''
const baseUrl = apiClient.defaults.baseURL || 'http://127.0.0.1:8000'
// Preload next face
if (currentIdx + 1 < faces.length) {

View File

@ -41,8 +41,7 @@ export default function ReportedPhotos() {
// Create direct backend URLs for images (only for non-video photos)
const newImageUrls: Record<number, string> = {}
// Use relative path when baseURL is empty (works with proxy and HTTPS)
const baseURL = apiClient.defaults.baseURL || ''
const baseURL = apiClient.defaults.baseURL || 'http://10.0.10.121:8000'
response.items.forEach((reported) => {
if (reported.photo_id && reported.photo_media_type !== 'video') {
// Use direct backend URL - the backend endpoint doesn't require auth for images