Skip to content

Commit ad55b39

Browse files
committed
feat: enable previews for staging
1 parent 7fd017a commit ad55b39

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

apps/wallet-ui/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Root domain for the app
22
NEXT_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
46
NEXT_PUBLIC_THIRDWEB_CLIENT_ID=
57
# Thirdweb API key

apps/wallet-ui/src/hooks/useRouter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable no-restricted-imports */
22

3-
import { isDevelopment } from "@/lib/utils";
3+
import { isMultiTenant } from "@/lib/utils";
44
import { useRouter as useNextRouter } from "next/navigation";
55

66
export 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);

apps/wallet-ui/src/lib/redirect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { 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
*/
88
export function redirect(path: string, ecosystemId: string) {
9-
if (isDevelopment) {
9+
if (isMultiTenant) {
1010
return nextRedirect(`/${ecosystemId}${path}`);
1111
}
1212
return nextRedirect(path);

apps/wallet-ui/src/lib/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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";

apps/wallet-ui/src/middleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type NextRequest, NextResponse } from "next/server";
2-
import { isDevelopment } from "./lib/utils";
2+
import { isMultiTenant } from "./lib/utils";
33

44
export 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

0 commit comments

Comments
 (0)