fix auth
This commit is contained in:
@@ -33,10 +33,18 @@ export default function ProductsPage() {
|
||||
|
||||
// Fetch products and categories
|
||||
useEffect(() => {
|
||||
const authToken = document.cookie
|
||||
.split("; ")
|
||||
.find((row) => row.startsWith("Authorization="))
|
||||
?.split("=")[1];
|
||||
|
||||
if (!authToken) {
|
||||
router.push("/login");
|
||||
return;
|
||||
}
|
||||
|
||||
const fetchDataAsync = async () => {
|
||||
try {
|
||||
const authToken = document.cookie.split("Authorization=")[1];
|
||||
|
||||
const [fetchedProducts, fetchedCategories] = await Promise.all([
|
||||
fetchProductData(
|
||||
`${process.env.NEXT_PUBLIC_API_URL}/products`,
|
||||
|
||||
Reference in New Issue
Block a user