|
55 | 55 |
|
56 | 56 | // Get ArgoCD auth token from localStorage and add to headers |
57 | 57 | const authToken = window.localStorage.getItem('argocd.token'); |
| 58 | + console.log('[GlueOps Extension] Auth token found:', authToken ? 'YES (length: ' + authToken.length + ')' : 'NO'); |
58 | 59 | if (authToken) { |
59 | 60 | headers.set('Authorization', `Bearer ${authToken}`); |
60 | 61 | } |
61 | 62 |
|
| 63 | + // Debug: log all cookies |
| 64 | + console.log('[GlueOps Extension] Document cookies:', document.cookie ? 'Present' : 'None'); |
| 65 | + console.log('[GlueOps Extension] Has _oauth2_proxy cookie:', document.cookie.includes('_oauth2_proxy')); |
| 66 | + |
| 67 | + const url = `/extensions/glueops-links-extension/api/v1/applications/${appName}/links`; |
| 68 | + console.log('[GlueOps Extension] Fetching:', url); |
| 69 | + console.log('[GlueOps Extension] Headers:', { |
| 70 | + 'Accept': headers.get('Accept'), |
| 71 | + 'Argocd-Application-Name': headers.get('Argocd-Application-Name'), |
| 72 | + 'Argocd-Project-Name': headers.get('Argocd-Project-Name'), |
| 73 | + 'Authorization': authToken ? 'Bearer <token>' : 'None' |
| 74 | + }); |
| 75 | + |
62 | 76 | // Create abort controller for timeout |
63 | 77 | const controller = new AbortController(); |
64 | 78 | const timeoutId = setTimeout(() => controller.abort(), 5000); |
65 | 79 |
|
66 | 80 | try { |
67 | 81 | // Call ArgoCD proxy extension API |
68 | | - const response = await fetch(`/extensions/glueops-links-extension/api/v1/applications/${appName}/links`, { |
| 82 | + const response = await fetch(url, { |
69 | 83 | method: 'GET', |
70 | 84 | credentials: 'include', |
71 | 85 | headers: headers, |
72 | 86 | signal: controller.signal |
73 | 87 | }); |
74 | 88 | clearTimeout(timeoutId); |
75 | 89 |
|
| 90 | + console.log('[GlueOps Extension] Response status:', response.status); |
| 91 | + console.log('[GlueOps Extension] Response headers:', { |
| 92 | + 'content-type': response.headers.get('content-type'), |
| 93 | + 'content-length': response.headers.get('content-length') |
| 94 | + }); |
| 95 | + |
76 | 96 | if (!response.ok) { |
77 | 97 | // Server returned error status |
| 98 | + console.error('[GlueOps Extension] Error response:', response.status, response.statusText); |
| 99 | + const text = await response.text(); |
| 100 | + console.error('[GlueOps Extension] Error body:', text.substring(0, 200)); |
78 | 101 | setError('offline'); |
79 | 102 | setCategories([]); |
80 | 103 | return; |
81 | 104 | } |
82 | 105 | const data = await response.json(); |
| 106 | + console.log('[GlueOps Extension] Success! Categories:', data.categories?.length || 0); |
83 | 107 |
|
84 | 108 | // Extract categories array and metadata from API response |
85 | 109 | setCategories(data.categories || []); |
86 | 110 | setLastUpdated(data.metadata.last_updated); |
87 | 111 | setMaxRows(data.metadata.max_rows); |
88 | 112 | } catch (fetchErr) { |
89 | 113 | clearTimeout(timeoutId); |
| 114 | + console.error('[GlueOps Extension] Fetch error:', fetchErr.message); |
90 | 115 | throw fetchErr; |
91 | 116 | } |
92 | 117 | } catch (err) { |
93 | 118 | // Network error, timeout, or other fetch failure |
| 119 | + console.error('[GlueOps Extension] Top-level error:', err.message, err.name); |
94 | 120 | // Silently handle - don't crash ArgoCD |
95 | 121 | setError('offline'); |
96 | 122 | setCategories([]); |
|
0 commit comments