diff --git a/client/kb-frontend/src/App.jsx b/client/kb-frontend/src/App.jsx index a11d4e6..26b7fd4 100644 --- a/client/kb-frontend/src/App.jsx +++ b/client/kb-frontend/src/App.jsx @@ -65,7 +65,7 @@ function App() { }; const fetchArticles = () => { - fetch('http://localhost:9000/api/articles', { + fetch('/api/articles', { headers: { 'Authorization': `Bearer ${token}` }, @@ -97,7 +97,7 @@ function App() { fetchArticles(); } - fetch(`http://localhost:9000/api/search/advanced?${params.toString()}`, { + fetch(`/api/search/advanced?${params.toString()}`, { headers: { 'Authorization': `Bearer ${token}` } @@ -130,7 +130,7 @@ function App() { const isNew = !updatedArticle.ka_number || updatedArticle.ka_number === 'New Article'; if (isNew) { - fetch('http://localhost:9000/api/articles', { + fetch('/api/articles', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -146,7 +146,7 @@ function App() { }) .catch(error => console.error('Error creating article:', error)); } else { - fetch(`http://localhost:9000/api/articles/${updatedArticle.ka_number}`, { + fetch(`/api/articles/${updatedArticle.ka_number}`, { method: 'PUT', headers: { 'Content-Type': 'application/json', @@ -176,7 +176,7 @@ function App() { const handleCreateNew = async () => { try { - const response = await fetch('http://localhost:9000/api/articles', { + const response = await fetch('/api/articles', { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, @@ -205,7 +205,7 @@ function App() { const handleDelete = () => { if (confirm('Are you sure you want to delete this article?')) { - fetch(`http://localhost:9000/api/articles/${selectedArticle.ka_number}`, { + fetch(`/api/articles/${selectedArticle.ka_number}`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${token}` } }) diff --git a/client/kb-frontend/src/components/AdminPanel.jsx b/client/kb-frontend/src/components/AdminPanel.jsx index f10916b..3ba30cb 100644 --- a/client/kb-frontend/src/components/AdminPanel.jsx +++ b/client/kb-frontend/src/components/AdminPanel.jsx @@ -14,7 +14,7 @@ function AdminPanel({ token, onBack }) { const fetchUsers = async () => { try { - const response = await fetch('http://localhost:9000/api/admin/users', { + const response = await fetch('/api/admin/users', { headers: { 'Authorization': `Bearer ${token}` } @@ -41,7 +41,7 @@ function AdminPanel({ token, onBack }) { const handleSaveRole = async (userId) => { try { - const response = await fetch(`http://localhost:9000/api/admin/users/${userId}/role`, { + const response = await fetch(`/api/admin/users/${userId}/role`, { method: 'PUT', headers: { 'Authorization': `Bearer ${token}`, @@ -76,7 +76,7 @@ function AdminPanel({ token, onBack }) { } try { - const response = await fetch(`http://localhost:9000/api/admin/users/${userId}`, { + const response = await fetch(`/api/admin/users/${userId}`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${token}` diff --git a/client/kb-frontend/src/components/ArticleEdit.jsx b/client/kb-frontend/src/components/ArticleEdit.jsx index e98243a..d3f40c6 100644 --- a/client/kb-frontend/src/components/ArticleEdit.jsx +++ b/client/kb-frontend/src/components/ArticleEdit.jsx @@ -125,7 +125,7 @@ function ArticleEditor({ article, onSave, onCancel, token }) { const fetchCategories = async () => { try { - const response = await fetch('http://localhost:9000/api/categories', { + const response = await fetch('/api/categories', { headers: { 'Authorization': `Bearer ${token}` } @@ -142,7 +142,7 @@ function ArticleEditor({ article, onSave, onCancel, token }) { const fetchTags = async () => { try { - const response = await fetch('http://localhost:9000/api/tags', { + const response = await fetch('/api/tags', { headers: { 'Authorization': `Bearer ${token}` } @@ -171,7 +171,7 @@ function ArticleEditor({ article, onSave, onCancel, token }) { onSave(articleData); try { - await fetch(`http://localhost:9000/api/articles/${article.ka_number}/categories`, { + await fetch(`/api/articles/${article.ka_number}/categories`, { method: 'PUT', headers: { 'Authorization': `Bearer ${token}`, @@ -180,7 +180,7 @@ function ArticleEditor({ article, onSave, onCancel, token }) { body: JSON.stringify({ categories: selectedCategories }) }); - await fetch(`http://localhost:9000/api/articles/${article.ka_number}/tags`, { + await fetch(`/api/articles/${article.ka_number}/tags`, { method: 'PUT', headers: { 'Authorization': `Bearer ${token}`, @@ -222,7 +222,7 @@ function ArticleEditor({ article, onSave, onCancel, token }) { if (!quill) return; const range = quill.getSelection(true); - const mediaUrl = `http://localhost:9000${mediaItem.url}`; + const mediaUrl = `/${mediaItem.url}`; if (mediaItem.type === 'image') { quill.insertEmbed(range.index, 'image', mediaUrl); @@ -241,7 +241,7 @@ function ArticleEditor({ article, onSave, onCancel, token }) { if (!newCategoryInput.trim()) return; try { - const response = await fetch('http://localhost:9000/api/categories', { + const response = await fetch('/api/categories', { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, diff --git a/client/kb-frontend/src/components/DraftsList.jsx b/client/kb-frontend/src/components/DraftsList.jsx index 9ac8768..824f588 100644 --- a/client/kb-frontend/src/components/DraftsList.jsx +++ b/client/kb-frontend/src/components/DraftsList.jsx @@ -12,7 +12,7 @@ function DraftsList({ token, onBack, onSelectDraft }) { const fetchDrafts = async () => { try { - const response = await fetch('http://localhost:9000/api/articles/drafts', { + const response = await fetch('\/api/articles/drafts', { headers: { 'Authorization': `Bearer ${token}` } @@ -38,7 +38,7 @@ function DraftsList({ token, onBack, onSelectDraft }) { if(!confirm('Are you sure you want to delete this draft?')) return; try { - const response = await fetch(`http://localhost:9000/api/articles/${kaNumber}`, { + const response = await fetch(`/api/articles/${kaNumber}`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${token}` diff --git a/client/kb-frontend/src/components/FilterBar.jsx b/client/kb-frontend/src/components/FilterBar.jsx index 5905eae..19f6c18 100644 --- a/client/kb-frontend/src/components/FilterBar.jsx +++ b/client/kb-frontend/src/components/FilterBar.jsx @@ -30,7 +30,7 @@ function FilterBar({ token, onFilterChange }) { const fetchCategories = async () => { try { - const response = await fetch('http://localhost:9000/api/categories', { + const response = await fetch('/api/categories', { headers: { 'Authorization': `Bearer ${token}` } @@ -47,7 +47,7 @@ function FilterBar({ token, onFilterChange }) { const fetchTags = async () => { try { - const response = await fetch('http://localhost:9000/api/tags', { + const response = await fetch('/api/tags', { headers: { 'Authorization': `Bearer ${token}` } diff --git a/client/kb-frontend/src/components/Login.jsx b/client/kb-frontend/src/components/Login.jsx index 37e4fd2..39d0200 100644 --- a/client/kb-frontend/src/components/Login.jsx +++ b/client/kb-frontend/src/components/Login.jsx @@ -35,7 +35,7 @@ function Login({ onLoginSuccess, onSwitchToRegister }) { setLoading(true); try { - const response = await fetch('http://localhost:9000/api/auth/login', { + const response = await fetch('/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' @@ -76,7 +76,7 @@ function Login({ onLoginSuccess, onSwitchToRegister }) { const loginResponse = await msalInstance.loginPopup(loginRequest); // Send the access token to your backend - const response = await fetch('http://localhost:9000/api/auth/microsoft', { + const response = await fetch('/api/auth/microsoft', { method: 'POST', headers: { 'Content-Type': 'application/json' diff --git a/client/kb-frontend/src/components/MediaGallery.jsx b/client/kb-frontend/src/components/MediaGallery.jsx index 4d70c3f..a7ae7f2 100644 --- a/client/kb-frontend/src/components/MediaGallery.jsx +++ b/client/kb-frontend/src/components/MediaGallery.jsx @@ -44,7 +44,7 @@ function MediaGallery({ kaNumber, token, onInsertMedia, isOpen, onToggle }) { formData.append('file', file); try { - const response = await fetch(`http://localhost:9000/api/articles/${kaNumber}/media`, { + const response = await fetch(`/api/articles/${kaNumber}/media`, { method: 'POST', headers: { 'Authorization': `Bearer ${token}` @@ -72,7 +72,7 @@ function MediaGallery({ kaNumber, token, onInsertMedia, isOpen, onToggle }) { if (!confirm('Are you sure you want to delete this file?')) return; try { - const response = await fetch(`http://localhost:9000/api/articles/${kaNumber}/media/${filename}`, { + const response = await fetch(`/api/articles/${kaNumber}/media/${filename}`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${token}` @@ -139,7 +139,7 @@ function MediaGallery({ kaNumber, token, onInsertMedia, isOpen, onToggle }) {