Move admin area to root subdomain
CI / quality (push) Waiting to run

This commit is contained in:
MOH
2026-03-12 00:15:12 +01:00
parent e7dab6f0ef
commit 87a597c872
50 changed files with 256 additions and 140 deletions
+16 -15
View File
@@ -7,6 +7,7 @@ import { isRedirectError } from "next/dist/client/components/redirect";
import { ZodError } from "zod";
import { routing } from "@/i18n/routing";
import { toInternalAdminPath } from "@/lib/admin-routing";
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
import { deleteEntityMediaUsages, replaceEntityMediaUsages } from "@/lib/media";
import { resolveMediaSelection } from "@/lib/media-service";
@@ -25,7 +26,7 @@ import {
function ensureAdmin() {
if (!isAdminAuthenticated()) {
clearAdminSessionCookie();
redirect("/root");
redirect("/");
}
}
@@ -85,11 +86,11 @@ function parseZodError(error: ZodError) {
}
async function revalidatePortfolioPages() {
revalidatePath("/root");
revalidatePath("/root/media");
revalidatePath("/root/portfolio");
revalidatePath("/root/portfolio/categories");
revalidatePath("/root/portfolio/projects");
revalidatePath(toInternalAdminPath("/"));
revalidatePath(toInternalAdminPath("/media"));
revalidatePath(toInternalAdminPath("/portfolio"));
revalidatePath(toInternalAdminPath("/portfolio/categories"));
revalidatePath(toInternalAdminPath("/portfolio/projects"));
revalidatePath("/portfolio");
for (const locale of routing.locales) {
@@ -106,7 +107,7 @@ async function removeManagedPaths(paths: string[]) {
export async function upsertCategoryAction(formData: FormData) {
ensureAdmin();
const redirectPath = getRedirectPath(formData, "/root/portfolio/categories");
const redirectPath = getRedirectPath(formData, "/portfolio/categories");
try {
const parsed = categoryInputSchema.parse({
@@ -156,7 +157,7 @@ export async function upsertCategoryAction(formData: FormData) {
export async function deleteCategoryAction(formData: FormData) {
ensureAdmin();
const redirectPath = getRedirectPath(formData, "/root/portfolio/categories");
const redirectPath = getRedirectPath(formData, "/portfolio/categories");
const id = String(formData.get("id") ?? "");
try {
@@ -191,8 +192,8 @@ export async function saveProjectAction(formData: FormData) {
ensureAdmin();
const fallbackRedirect = String(formData.get("id") ?? "").trim()
? `/root/portfolio/projects/${String(formData.get("id") ?? "").trim()}`
: "/root/portfolio/projects/new";
? `/portfolio/projects/${String(formData.get("id") ?? "").trim()}`
: "/portfolio/projects/new";
const redirectPath = getRedirectPath(formData, fallbackRedirect);
const uploadedPaths: string[] = [];
const createdMediaAssetIds: string[] = [];
@@ -517,7 +518,7 @@ export async function saveProjectAction(formData: FormData) {
});
await revalidatePortfolioPages();
revalidatePath(`/root/portfolio/projects/${projectResult.project.id}`);
revalidatePath(toInternalAdminPath(`/portfolio/projects/${projectResult.project.id}`));
revalidatePath(`/portfolio/${projectResult.project.slug}`);
for (const locale of routing.locales) {
@@ -525,7 +526,7 @@ export async function saveProjectAction(formData: FormData) {
}
redirect(
withMessage(`/root/portfolio/projects/${projectResult.project.id}`, "success", "Projekt gespeichert."),
withMessage(`/portfolio/projects/${projectResult.project.id}`, "success", "Projekt gespeichert."),
);
} catch (error) {
if (isRedirectError(error)) {
@@ -578,7 +579,7 @@ export async function deleteProjectAction(formData: FormData) {
});
if (!project) {
redirect(withMessage("/root/portfolio", "error", "Project not found."));
redirect(withMessage("/portfolio", "error", "Project not found."));
}
await prisma.portfolioProject.delete({
@@ -595,12 +596,12 @@ export async function deleteProjectAction(formData: FormData) {
revalidatePath(getLocalizedPath(locale, `/portfolio/${project.slug}`));
}
redirect(withMessage("/root/portfolio", "success", "Project deleted."));
redirect(withMessage("/portfolio", "success", "Project deleted."));
} catch (error) {
if (isRedirectError(error)) {
throw error;
}
redirect(withMessage("/root/portfolio", "error", "Unable to delete project."));
redirect(withMessage("/portfolio", "error", "Unable to delete project."));
}
}
+2 -2
View File
@@ -24,14 +24,14 @@ const copy = {
export default async function RootPortfolioCategoriesPage() {
if (!isAdminAuthenticated()) {
redirect("/root");
redirect("/");
}
async function logoutAction() {
"use server";
clearAdminSessionCookie();
redirect("/root");
redirect("/");
}
const categories = await getAdminPortfolioCategories();
+1 -1
View File
@@ -1,5 +1,5 @@
import { redirect } from "next/navigation";
export default function RootPortfolioMediaRedirectPage() {
redirect("/root/media");
redirect("/media");
}
+2 -2
View File
@@ -31,14 +31,14 @@ type RootPortfolioPageProps = {
export default async function RootPortfolioPage({ searchParams }: RootPortfolioPageProps) {
if (!isAdminAuthenticated()) {
redirect("/root");
redirect("/");
}
async function logoutAction() {
"use server";
clearAdminSessionCookie();
redirect("/root");
redirect("/");
}
const selectedCategory = searchParams?.category && searchParams.category !== "__all__"
+4 -4
View File
@@ -53,14 +53,14 @@ export default async function RootPortfolioProjectPage({
params,
}: RootPortfolioProjectPageProps) {
if (!isAdminAuthenticated()) {
redirect("/root");
redirect("/");
}
async function logoutAction() {
"use server";
clearAdminSessionCookie();
redirect("/root");
redirect("/");
}
const [categories, mediaOptions, project] = await Promise.all([
@@ -70,7 +70,7 @@ export default async function RootPortfolioProjectPage({
]);
if (!project) {
redirect("/root/portfolio?error=Project+not+found.");
redirect("/portfolio?error=Project+not+found.");
}
return (
@@ -90,7 +90,7 @@ export default async function RootPortfolioProjectPage({
mediaOptions={mediaOptions}
project={project}
formId="portfolio-project-form"
redirectPath={`/root/portfolio/projects/${project.id}`}
redirectPath={`/portfolio/projects/${project.id}`}
/>
</MotionFade>
+3 -3
View File
@@ -26,14 +26,14 @@ const copy = {
export default async function RootNewPortfolioProjectPage() {
if (!isAdminAuthenticated()) {
redirect("/root");
redirect("/");
}
async function logoutAction() {
"use server";
clearAdminSessionCookie();
redirect("/root");
redirect("/");
}
const [categories, mediaOptions] = await Promise.all([
@@ -57,7 +57,7 @@ export default async function RootNewPortfolioProjectPage() {
categories={categories}
mediaOptions={mediaOptions}
formId="portfolio-project-form"
redirectPath="/root/portfolio/projects/new"
redirectPath="/portfolio/projects/new"
/>
</MotionFade>
</div>
+2 -2
View File
@@ -31,14 +31,14 @@ export default async function RootPortfolioProjectsPage({
searchParams,
}: RootPortfolioProjectsPageProps) {
if (!isAdminAuthenticated()) {
redirect("/root");
redirect("/");
}
async function logoutAction() {
"use server";
clearAdminSessionCookie();
redirect("/root");
redirect("/");
}
const selectedCategory = searchParams?.category && searchParams.category !== "__all__"