add middleware
Browse filesFiles changed (4)
12345678import { NextRequest, NextResponse } from "next/server";export async function GET(req: NextRequest) {const host = req.headers.get("host") ?? "localhost:3000";console.log(req.headers);const redirect_uri =`${host.includes("localhost") ? "http://" : "https://"}` +12345678910import { NextRequest, NextResponse } from "next/server";export async function GET(req: NextRequest) {const host =req.headers.get("x-current-host") ??req.headers.get("host") ??"localhost:3000";const redirect_uri =`${host.includes("localhost") ? "http://" : "https://"}` +
12345678910import { redirect } from "next/navigation";import { Metadata } from "next";import { apiServer } from "@/lib/api";async function getLoginUrl() {try {const res = await apiServer.get("/auth");return res.data;} catch (error) {return error;123456789101112131415161718import { redirect } from "next/navigation";import { Metadata } from "next";import { headers } from "next/headers";import { apiServer } from "@/lib/api";async function getLoginUrl() {const headersList = await headers();const pathname = headersList.get("x-current-host") || "/";try {const res = await apiServer.get("/auth", {headers: {"x-current-host": pathname,},});return res.data;} catch (error) {return error;
54 unmodified lines555657585960612 unmodified lines6465666768697054 unmodified linesreturn (<><Buttonvariant="sky"className="max-lg:hidden !px-4"onClick={updateSpace}>2 unmodified lines{loading && <Loading className="ml-2 size-4 animate-spin" />}</Button><Buttonvariant="sky"size="sm"className="lg:hidden"onClick={updateSpace}54 unmodified lines555657585960612 unmodified lines6465666768697054 unmodified linesreturn (<><Buttonvariant="default"className="max-lg:hidden !px-4"onClick={updateSpace}>2 unmodified lines{loading && <Loading className="ml-2 size-4 animate-spin" />}</Button><Buttonvariant="default"size="sm"className="lg:hidden"onClick={updateSpace}
123456789101112import { NextResponse } from "next/server";import type { NextRequest } from "next/server";
export function middleware(request: NextRequest) { const headers = new Headers(request.headers); headers.set("x-current-host", request.nextUrl.host); return NextResponse.next({ headers });}
export const config = { matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],};app/api/auth/route.ts+4-2
app/auth/page.tsx+9-1
components/editor/save-button/index.tsx+2-2
middleware.tsAdded+12