diff --git a/front-end/src/index.js b/front-end/src/index.js index b4518ad..1c3265d 100644 --- a/front-end/src/index.js +++ b/front-end/src/index.js @@ -5,7 +5,7 @@ import App from './App'; import axios from 'axios'; // base URL for all Axios requests -axios.defaults.baseURL = 'http://localhost:3001/api'; +axios.defaults.baseURL = 'http://readtrack-yi3cj.ondigitalocean.app/'; // using interceptor to attach the token to every request axios.interceptors.request.use(function (config) { diff --git a/front-end/src/pages/Book.js b/front-end/src/pages/Book.js index 5c317d6..9f22c43 100644 --- a/front-end/src/pages/Book.js +++ b/front-end/src/pages/Book.js @@ -23,7 +23,7 @@ const BookPage = ({ loggedInUser }) => { const toggleFavorite = () => { const token = localStorage.getItem("token"); - fetch(`http://localhost:3001/api/users/${loggedInUser._id}/favorites`, { + fetch(`https://readtrack-yi3cj.ondigitalocean.app/api/users/${loggedInUser._id}/favorites`, { method: "POST", headers: { Authorization: `Bearer ${token}`, @@ -49,7 +49,7 @@ const BookPage = ({ loggedInUser }) => { useEffect(() => { const token = localStorage.getItem("token"); if (bookId && token) { - fetch(`http://localhost:3001/api/books/${bookId}`, { + fetch(`https://readtrack-yi3cj.ondigitalocean.app/api/books/${bookId}`, { method: "GET", headers: { 'Authorization': `Bearer ${token}`, @@ -84,7 +84,7 @@ const BookPage = ({ loggedInUser }) => { setIsFavorite(bookData.isFavorite); - fetch(`http://localhost:3001/api/users/${loggedInUser._id}/books`, { + fetch(`https://readtrack-yi3cj.ondigitalocean.app/api/users/${loggedInUser._id}/books`, { method: "GET", headers: { 'Authorization': `Bearer ${token}`, diff --git a/front-end/src/pages/BookSearch.js b/front-end/src/pages/BookSearch.js index 5688906..5e30a28 100644 --- a/front-end/src/pages/BookSearch.js +++ b/front-end/src/pages/BookSearch.js @@ -11,7 +11,7 @@ const BookSearchPage = () => { }, []); const fetchAllBooks = () => { - const apiUrl = `http://localhost:3001/api/books`; + const apiUrl = `https://readtrack-yi3cj.ondigitalocean.app/api/books`; const token = localStorage.getItem('token'); const headers = { 'Authorization': `Bearer ${token}` @@ -37,7 +37,7 @@ const BookSearchPage = () => { }; const handleSearch = (searchTerm) => { - const searchUrl = `http://localhost:3001/api/books/search?query=${encodeURIComponent(searchTerm)}`; + const searchUrl = `https://readtrack-yi3cj.ondigitalocean.app/api/books/search?query=${encodeURIComponent(searchTerm)}`; const token = localStorage.getItem('token'); const headers = { 'Authorization': `Bearer ${token}` }; diff --git a/front-end/src/pages/CurrentlyReading.js b/front-end/src/pages/CurrentlyReading.js index d9fe748..4fc5e02 100644 --- a/front-end/src/pages/CurrentlyReading.js +++ b/front-end/src/pages/CurrentlyReading.js @@ -12,7 +12,7 @@ function CurrentlyReading({ userId, bookId, isAdded }) { const token = localStorage.getItem("token"); const method = bookAdded ? "DELETE" : "POST"; - fetch(`http://localhost:3001/api/users/${userId}/currentlyReading`, { + fetch(`https://readtrack-yi3cj.ondigitalocean.app/api/users/${userId}/currentlyReading`, { method: method, headers: { 'Authorization': `Bearer ${token}`, diff --git a/front-end/src/pages/Form/SignUpPage.js b/front-end/src/pages/Form/SignUpPage.js index 55e4d60..53fe0b3 100644 --- a/front-end/src/pages/Form/SignUpPage.js +++ b/front-end/src/pages/Form/SignUpPage.js @@ -16,7 +16,7 @@ const SignUpPage = ({ setLoggedInUser, loggedInUser, setRegisteredUser }) => { const handleSubmit = (e) => { e.preventDefault(); - fetch('http://localhost:3001/api/register', { + fetch('https://readtrack-yi3cj.ondigitalocean.app/api/register', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/front-end/src/pages/Form/editProfile.js b/front-end/src/pages/Form/editProfile.js index 4d04f82..6f05c39 100644 --- a/front-end/src/pages/Form/editProfile.js +++ b/front-end/src/pages/Form/editProfile.js @@ -37,7 +37,7 @@ const EditProfile = ({ loggedInUser, setLoggedInUser }) => { const token = localStorage.getItem("token"); try { const response = await fetch( - `http://localhost:3001/api/users/update/${loggedInUser._id}`, + `https://readtrack-yi3cj.ondigitalocean.app/api/users/update/${loggedInUser._id}`, { method: "PUT", headers: { diff --git a/front-end/src/pages/Form/login.js b/front-end/src/pages/Form/login.js index 9f278e6..228961a 100644 --- a/front-end/src/pages/Form/login.js +++ b/front-end/src/pages/Form/login.js @@ -32,7 +32,7 @@ const Login = ({ registeredUser, setLoggedInUser }) => { } try { - const response = await fetch('http://localhost:3001/api/login', { + const response = await fetch('https://readtrack-yi3cj.ondigitalocean.app/api/login', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/front-end/src/pages/Form/profile.js b/front-end/src/pages/Form/profile.js index 15b3a0e..e112d43 100644 --- a/front-end/src/pages/Form/profile.js +++ b/front-end/src/pages/Form/profile.js @@ -22,7 +22,7 @@ const ProfilePage = ({ loggedInUser, setLoggedInUser }) => { const fetchUserProfile = async () => { try { - const response = await fetch(`http://localhost:3001/api/users/${loggedInUser._id}`, { + const response = await fetch(`https://readtrack-yi3cj.ondigitalocean.app/api/users/${loggedInUser._id}`, { method: 'GET', headers: { 'Authorization': `Bearer ${token}`, @@ -42,7 +42,7 @@ const ProfilePage = ({ loggedInUser, setLoggedInUser }) => { const fetchBooks = async (endpoint, setBooks) => { try { - const response = await fetch(`http://localhost:3001/api/users/${loggedInUser._id}/books/${endpoint}`, { + const response = await fetch(`https://readtrack-yi3cj.ondigitalocean.app/api/users/${loggedInUser._id}/books/${endpoint}`, { method: 'GET', headers: { 'Authorization': `Bearer ${token}` diff --git a/front-end/src/pages/Friends.js b/front-end/src/pages/Friends.js index a96f800..f7a290d 100644 --- a/front-end/src/pages/Friends.js +++ b/front-end/src/pages/Friends.js @@ -10,7 +10,7 @@ const Friends = ({ loggedInUser, setLoggedInUser }) => { useEffect(() => { if (loggedInUser) { - fetch(`http://localhost:3001/api/users/${loggedInUser._id}`) + fetch(`https://readtrack-yi3cj.ondigitalocean.app/api/users/${loggedInUser._id}`) .then((response) => response.json()) .then((data) => { setProfile(data); diff --git a/front-end/src/pages/ReadingFinished.js b/front-end/src/pages/ReadingFinished.js index 6c284f4..01d8de8 100644 --- a/front-end/src/pages/ReadingFinished.js +++ b/front-end/src/pages/ReadingFinished.js @@ -11,7 +11,7 @@ function ReadingFinished({ userId, bookId, isAdded }) { const token = localStorage.getItem("token"); const method = bookAdded ? "DELETE" : "POST"; - fetch(`http://localhost:3001/api/users/${userId}/finishedReading`, { + fetch(`https://readtrack-yi3cj.ondigitalocean.app/api/users/${userId}/finishedReading`, { method: method, headers: { 'Authorization': `Bearer ${token}`, diff --git a/front-end/src/pages/ReadingWishlist.js b/front-end/src/pages/ReadingWishlist.js index fa8e1ec..26408e6 100644 --- a/front-end/src/pages/ReadingWishlist.js +++ b/front-end/src/pages/ReadingWishlist.js @@ -11,7 +11,7 @@ function ReadingWishlist({ userId, bookId, isAdded }) { const token = localStorage.getItem("token"); const method = bookAdded ? "DELETE" : "POST"; - fetch(`http://localhost:3001/api/users/${userId}/wishlist`, { + fetch(`https://readtrack-yi3cj.ondigitalocean.app/api/users/${userId}/wishlist`, { method: method, headers: { Authorization: `Bearer ${token}`, diff --git a/front-end/src/pages/mainHome.js b/front-end/src/pages/mainHome.js index 32def4c..532742f 100644 --- a/front-end/src/pages/mainHome.js +++ b/front-end/src/pages/mainHome.js @@ -23,10 +23,10 @@ const MainHome = ({ loggedInUser, setLoggedInUser }) => { const token = localStorage.getItem("token"); const urls = [ - `http://localhost:3001/api/users/${loggedInUser._id}/books/currentReads`, - `http://localhost:3001/api/users/${loggedInUser._id}/books/friendsReads`, - `http://localhost:3001/api/users/${loggedInUser._id}/books/topReads`, - `http://localhost:3001/api/users/${loggedInUser._id}/books/suggestions`, + `https://readtrack-yi3cj.ondigitalocean.app/api/users/${loggedInUser._id}/books/currentReads`, + `https://readtrack-yi3cj.ondigitalocean.app/api/users/${loggedInUser._id}/books/friendsReads`, + `https://readtrack-yi3cj.ondigitalocean.app/api/users/${loggedInUser._id}/books/topReads`, + `https://readtrack-yi3cj.ondigitalocean.app/api/users/${loggedInUser._id}/books/suggestions`, ]; try { @@ -55,7 +55,7 @@ const MainHome = ({ loggedInUser, setLoggedInUser }) => { // Fetch the full book details using the googleBookId const fetchBookDetails = async (bookRefs) => { const bookDetailsRequests = bookRefs.map((bookRef) => - fetch(`http://localhost:3001/api/books/${bookRef.id}`, { + fetch(`https://readtrack-yi3cj.ondigitalocean.app/api/books/${bookRef.id}`, { method: "GET", headers: { Authorization: `Bearer ${token}`,