From 7b0c90ce063a5cb40c5ca93c06045691f94265a3 Mon Sep 17 00:00:00 2001 From: swve Date: Mon, 13 Feb 2023 23:01:59 +0100 Subject: [PATCH] bugfix: links issue --- front/app/_orgs/[orgslug]/courses/page.tsx | 16 +++++++++------- front/middleware.ts | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/front/app/_orgs/[orgslug]/courses/page.tsx b/front/app/_orgs/[orgslug]/courses/page.tsx index d19e3026..b3da79c3 100644 --- a/front/app/_orgs/[orgslug]/courses/page.tsx +++ b/front/app/_orgs/[orgslug]/courses/page.tsx @@ -4,7 +4,7 @@ import { useRouter } from "next/navigation"; import React from "react"; import styled from "styled-components"; import { Title } from "../../../../components/UI/Elements/Styles/Title"; -import { getAPIUrl, getBackendUrl } from "../../../../services/config"; +import { getAPIUrl, getBackendUrl, getUriWithOrg } from "../../../../services/config"; import { deleteCourseFromBackend } from "../../../../services/courses/courses"; import useSWR, { mutate } from "swr"; import { swrFetcher } from "@services/utils/requests"; @@ -18,7 +18,7 @@ const CoursesIndexPage = (params: any) => { async function deleteCourses(course_id: any) { await deleteCourseFromBackend(course_id); - mutate(`${getAPIUrl()}courses/${orgslug}/page/1/limit/10`); + mutate(`${getAPIUrl()}courses/org_slug/${orgslug}/page/1/limit/10`); } // function to remove "course_" from the course_id @@ -30,7 +30,7 @@ const CoursesIndexPage = (params: any) => { <> Courses :{" "} - <Link href={"/courses/new"}> + <Link href={getUriWithOrg(orgslug, "/courses/new")}> <button>+</button> </Link>{" "} @@ -41,12 +41,14 @@ const CoursesIndexPage = (params: any) => { {courses.map((course: any) => (
+ - - + diff --git a/front/middleware.ts b/front/middleware.ts index b61a3830..c7fffed5 100644 --- a/front/middleware.ts +++ b/front/middleware.ts @@ -36,7 +36,7 @@ export default function middleware(req: NextRequest) { // if url starts with "/organizations" rewrite to path if (url.pathname.startsWith("/organizations")) { - url.pathname = url.pathname.replace("/organizations", `/organizations/${currentHost}`); + url.pathname = url.pathname.replace("/organizations", `/organizations${currentHost}`); // remove localhost:3000 from url url.pathname = url.pathname.replace(`localhost:3000`, ""); console.log(url);