This commit is contained in:
Philip Cheung 2024-10-08 15:29:36 +08:00
parent ae470a2e83
commit 73a1a4f0ca
2 changed files with 21 additions and 22 deletions

View File

@ -18,19 +18,19 @@ services:
- traefik.docker.network=traefik-public - traefik.docker.network=traefik-public
- traefik.constraint-label=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.allAndOne-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.entrypoints=http
- traefik.http.routers.frontend-https.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`) - traefik.http.routers.allAndOne-https.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)
- traefik.http.routers.frontend-https.entrypoints=https - traefik.http.routers.allAndOne-https.entrypoints=https
- traefik.http.routers.frontend-https.tls=true - traefik.http.routers.allAndOne-https.tls=true
- traefik.http.routers.frontend-https.tls.certresolver=le - traefik.http.routers.allAndOne-https.tls.certresolver=le
# Enable www redirection for HTTP and HTTPS # Enable www redirection for HTTP and HTTPS
- traefik.http.routers.frontend-https.middlewares=www-redirect - traefik.http.routers.allAndOne-https.middlewares=www-redirect
- traefik.http.routers.frontend-http.middlewares=https-redirect,www-redirect - traefik.http.routers.allAndOne-http.middlewares=https-redirect,www-redirect
networks: networks:
- traefik-public - traefik-public
- default - default

View File

@ -42,13 +42,12 @@ export async function fetchAboutus() {
accept: "application/json" accept: "application/json"
}; };
const url = `${process.env.NEXT_PUBLIC_API_URL}aboutUs/`; const url = `${process.env.NEXT_PUBLIC_API_URL}aboutUs/`;
console.log('Fetching from URL:', url);
try { try {
const response = await fetch(url, { headers }); const response = await fetch(url, { headers });
console.log('Response status:', response.status);
const result = await response.json(); const result = await response.json();
console.log('Fetched data:', result);
// Sort the result by index // Sort the result by index
const sortedResult: AboutusProps[] = result.data.sort((a: any, b: any) => a.index - b.index); const sortedResult: AboutusProps[] = result.data.sort((a: any, b: any) => a.index - b.index);
@ -72,10 +71,10 @@ export async function fetchCourses() {
try { try {
const response = await fetch(url, { headers }); const response = await fetch(url, { headers });
console.log('Response status:', response.status);
const result = await response.json(); const result = await response.json();
console.log('Fetched data:', result);
const coursesArray: CoursesProps[] = result.data.map((course: CoursesProps) => ({ const coursesArray: CoursesProps[] = result.data.map((course: CoursesProps) => ({
...course, ...course,
@ -89,7 +88,7 @@ export async function fetchCourses() {
return sortedCoursesArray; return sortedCoursesArray;
} catch (error) { } catch (error) {
console.error('Fetch error:', error);
throw error; throw error;
} }
} }
@ -100,14 +99,14 @@ export async function fetchCourse(id: string) {
}; };
const url = `${process.env.NEXT_PUBLIC_API_URL}course/${id}/`; const url = `${process.env.NEXT_PUBLIC_API_URL}course/${id}/`;
console.log('Fetching from URL:', url);
try { try {
const response = await fetch(url, { headers }); const response = await fetch(url, { headers });
console.log('Response status:', response.status);
var result: CoursesProps = await response.json(); var result: CoursesProps = await response.json();
console.log('Fetched data:', result);
if (result.info_images && Array.isArray(result.info_images)) { if (result.info_images && Array.isArray(result.info_images)) {
result.info_images.sort((a, b) => a.index - b.index); result.info_images.sort((a, b) => a.index - b.index);
@ -125,12 +124,12 @@ export async function fetchSettings() {
accept: "application/json" accept: "application/json"
}; };
const url = `${process.env.NEXT_PUBLIC_API_URL}setting/`; const url = `${process.env.NEXT_PUBLIC_API_URL}setting/`;
console.log('Fetching from URL:', url);
try { try {
const response = await fetch(url, { headers }); const response = await fetch(url, { headers });
console.log('Response status:', response.status);
const result: SettingsProps = await response.json(); const result: SettingsProps = await response.json();
console.log('Fetched data:', result);
return result; return result;
} }
catch (error) { catch (error) {