diff --git a/app/auth/login/page.tsx b/app/auth/login/page.tsx index 4066e29..bd94659 100644 --- a/app/auth/login/page.tsx +++ b/app/auth/login/page.tsx @@ -20,12 +20,12 @@ export default function LoginPage() { e.preventDefault(); setError(""); - const res = await fetchData("https://internal-api.inboxi.ng/api/auth/login", { + const res = await fetchData("http://localhost:3001/api/auth/login", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ username, password }), }); - + if (res.token) { document.cookie = `Authorization=${res.token}; path=/; Secure; SameSite=Strict; max-age=604800`; router.push("/dashboard"); diff --git a/app/dashboard/products/page.tsx b/app/dashboard/products/page.tsx index 67674d2..ac4e6fa 100644 --- a/app/dashboard/products/page.tsx +++ b/app/dashboard/products/page.tsx @@ -141,7 +141,6 @@ export default function ProductsPage() { await saveProductImage(`${process.env.NEXT_PUBLIC_API_URL}/products/${savedProduct._id}/image`, file, authToken); } - // Update state with the saved product setProducts((prevProducts) => { if (editing) { return prevProducts.map((product) => diff --git a/lib/productData.ts b/lib/productData.ts index e409aff..78e6e5a 100644 --- a/lib/productData.ts +++ b/lib/productData.ts @@ -40,7 +40,7 @@ export const saveProductImage = async(url: string, file:File, authToken: string) formData.append("file", file); return await fetchData(url, { - method: "POST", + method: "PUT", headers: { Authorization: `Bearer ${authToken}`, //"Content-Type": "multipart/form-data",