File tree Expand file tree Collapse file tree 5 files changed +10
-7
lines changed Expand file tree Collapse file tree 5 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 11# Root domain for the app
22NEXT_PUBLIC_ROOT_DOMAIN = localhost:3000
3+ # If set to production, multi-tenant subdomains will be used
4+ NEXT_PUBLIC_ENVIRONMENT = development
35# Thirdweb client ID
46NEXT_PUBLIC_THIRDWEB_CLIENT_ID =
57# Thirdweb API key
Original file line number Diff line number Diff line change 11/* eslint-disable no-restricted-imports */
22
3- import { isDevelopment } from "@/lib/utils" ;
3+ import { isMultiTenant } from "@/lib/utils" ;
44import { useRouter as useNextRouter } from "next/navigation" ;
55
66export function useRouter ( ) {
@@ -9,7 +9,7 @@ export function useRouter() {
99 return {
1010 ...router ,
1111 push : ( path : string , ecosystemId : string ) => {
12- if ( isDevelopment && ecosystemId ) {
12+ if ( isMultiTenant && ecosystemId ) {
1313 return router . push ( `/${ ecosystemId } ${ path } ` ) ;
1414 }
1515 return router . push ( path ) ;
Original file line number Diff line number Diff line change 11import { redirect as nextRedirect } from "next/navigation" ;
2- import { isDevelopment } from "./utils" ;
2+ import { isMultiTenant } from "./utils" ;
33
44/**
55 * Wraps Next's redirect to add the ecosystem ID if we're in development mode.
66 * In dev, we don't use subdomains. We can't move this to middleware because the edge runtime does not support the JWT verification.
77 */
88export function redirect ( path : string , ecosystemId : string ) {
9- if ( isDevelopment ) {
9+ if ( isMultiTenant ) {
1010 return nextRedirect ( `/${ ecosystemId } ${ path } ` ) ;
1111 }
1212 return nextRedirect ( path ) ;
Original file line number Diff line number Diff line change @@ -5,4 +5,5 @@ export function cn(...inputs: ClassValue[]) {
55 return twMerge ( clsx ( inputs ) ) ;
66}
77
8- export const isDevelopment = process . env . NODE_ENV === "development" ;
8+ export const isMultiTenant =
9+ process . env . NEXT_PUBLIC_ENVIRONMENT !== "production" ;
Original file line number Diff line number Diff line change 11import { type NextRequest , NextResponse } from "next/server" ;
2- import { isDevelopment } from "./lib/utils" ;
2+ import { isMultiTenant } from "./lib/utils" ;
33
44export const config = {
55 matcher : [
@@ -25,7 +25,7 @@ export default async function middleware(req: NextRequest) {
2525 } `;
2626
2727 // If running development environment, do not rewrite
28- if ( isDevelopment ) {
28+ if ( isMultiTenant ) {
2929 return NextResponse . next ( ) ;
3030 }
3131
You can’t perform that action at this time.
0 commit comments