Skip to content

Commit

Permalink
redirecting to /dream if user is not logged in and visits pricing page
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutlope committed Mar 24, 2023
1 parent 875661f commit 7c3e742
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";

// Redirect to /dream if the user is not logged in
export function middleware(request: NextRequest) {
let cookie = request.cookies.get("next-auth.session-token")?.value;
if (cookie) {
return NextResponse.next();
} else {
return NextResponse.redirect(new URL("/dream", request.url));
}
}

export const config = {
matcher: "/buy-credits",
};
2 changes: 1 addition & 1 deletion pages/buy-credits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Pricing() {
return (
<div className="flex mx-auto max-w-7xl overflow-visible flex-col items-center justify-center py-2 min-h-screen">
<Head>
<title>RoomGPT Pricing</title>
<title>Buy RoomGPT Credits</title>
</Head>
<Script src="https://js.stripe.com/v3/pricing-table.js" />
<Script src="https://cdn.paritydeals.com/banner.js" />
Expand Down

0 comments on commit 7c3e742

Please sign in to comment.