diff --git a/docker-compose.yml b/docker-compose.yml index 6984be3..2602c2a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,19 +18,19 @@ services: - traefik.docker.network=traefik-public - traefik.constraint-label=traefik-public - - traefik.http-frontend.loadbalancer.server.port=80 + - traefik.http-allAndOne.loadbalancer.server.port=80 - - traefik.http.routers.frontend-http.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`) - - traefik.http.routers.frontend-http.entrypoints=http + - traefik.http.routers.allAndOne-http.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`) + - traefik.http.routers.allAndOne-http.entrypoints=http - - traefik.http.routers.frontend-https.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`) - - traefik.http.routers.frontend-https.entrypoints=https - - traefik.http.routers.frontend-https.tls=true - - traefik.http.routers.frontend-https.tls.certresolver=le + - traefik.http.routers.allAndOne-https.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`) + - traefik.http.routers.allAndOne-https.entrypoints=https + - traefik.http.routers.allAndOne-https.tls=true + - traefik.http.routers.allAndOne-https.tls.certresolver=le # Enable www redirection for HTTP and HTTPS - - traefik.http.routers.frontend-https.middlewares=www-redirect - - traefik.http.routers.frontend-http.middlewares=https-redirect,www-redirect + - traefik.http.routers.allAndOne-https.middlewares=www-redirect + - traefik.http.routers.allAndOne-http.middlewares=https-redirect,www-redirect networks: - traefik-public - default diff --git a/utils/index.ts b/utils/index.ts index 7d59db4..147e6d6 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -42,13 +42,12 @@ export async function fetchAboutus() { accept: "application/json" }; const url = `${process.env.NEXT_PUBLIC_API_URL}aboutUs/`; - console.log('Fetching from URL:', url); + try { const response = await fetch(url, { headers }); - console.log('Response status:', response.status); + const result = await response.json(); - console.log('Fetched data:', result); - + // Sort the result by index const sortedResult: AboutusProps[] = result.data.sort((a: any, b: any) => a.index - b.index); @@ -72,10 +71,10 @@ export async function fetchCourses() { try { const response = await fetch(url, { headers }); - console.log('Response status:', response.status); + const result = await response.json(); - console.log('Fetched data:', result); + const coursesArray: CoursesProps[] = result.data.map((course: CoursesProps) => ({ ...course, @@ -89,7 +88,7 @@ export async function fetchCourses() { return sortedCoursesArray; } catch (error) { - console.error('Fetch error:', error); + throw error; } } @@ -100,14 +99,14 @@ export async function fetchCourse(id: string) { }; const url = `${process.env.NEXT_PUBLIC_API_URL}course/${id}/`; - console.log('Fetching from URL:', url); + try { const response = await fetch(url, { headers }); - console.log('Response status:', response.status); + var result: CoursesProps = await response.json(); - console.log('Fetched data:', result); + if (result.info_images && Array.isArray(result.info_images)) { result.info_images.sort((a, b) => a.index - b.index); @@ -125,12 +124,12 @@ export async function fetchSettings() { accept: "application/json" }; const url = `${process.env.NEXT_PUBLIC_API_URL}setting/`; - console.log('Fetching from URL:', url); + try { const response = await fetch(url, { headers }); - console.log('Response status:', response.status); + const result: SettingsProps = await response.json(); - console.log('Fetched data:', result); + return result; } catch (error) {