Skip to content

Commit

Permalink
feat: subdomain routing
Browse files Browse the repository at this point in the history
  • Loading branch information
bepyan committed Aug 23, 2024
1 parent 3ca1421 commit e43261f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { env } from "~/lib/env";

export const config = {
matcher: ["/((?!api/|_next/|_static/|_vercel|[\\w-]+\\.\\w+).*)"],
Expand All @@ -25,7 +24,7 @@ export function middleware(request: NextRequest) {
const path = `${url.pathname}${searchParams ? `?${searchParams}` : ""}`;

// 서브도메인으로 접근한 경우
if (env.NODE_ENV === "production" && isSubdomain(hostname)) {
if (isSubdomain(hostname)) {
const subdomain = hostname.split(".")[0];
return NextResponse.rewrite(new URL(`/i/${subdomain}${path}`, request.url));
}
Expand Down

0 comments on commit e43261f

Please sign in to comment.