Skip to content

Commit 8edb087

Browse files
committed
temp remove middleware
1 parent 03d869c commit 8edb087

1 file changed

Lines changed: 46 additions & 46 deletions

File tree

apps/web/middleware.ts

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { db } from "@cap/database";
1+
// import { db } from "@cap/database";
22
import { organizations } from "@cap/database/schema";
33
import { buildEnv, serverEnv } from "@cap/env";
44
import { eq } from "drizzle-orm";
@@ -66,51 +66,51 @@ export async function middleware(request: NextRequest) {
6666
try {
6767
// We're on a custom domain at this point
6868
// Only allow /s/ routes for custom domains
69-
if (!path.startsWith("/s/")) {
70-
const url = new URL(request.url);
71-
url.hostname = webUrl;
72-
return NextResponse.redirect(url);
73-
}
74-
75-
// Check if we have a cached verification
76-
const verifiedDomain = request.cookies.get("verified_domain");
77-
if (verifiedDomain?.value === hostname) return NextResponse.next();
78-
79-
// Query the space with this custom domain
80-
const [organization] = await db()
81-
.select()
82-
.from(organizations)
83-
.where(eq(organizations.customDomain, hostname));
84-
85-
if (!organization || !organization.domainVerified) {
86-
// If no verified custom domain found, redirect to main domain
87-
const url = new URL(request.url);
88-
url.hostname = webUrl;
89-
return NextResponse.redirect(url);
90-
}
91-
92-
// Set verification cookie for non-API routes too
93-
const response = NextResponse.next();
94-
response.cookies.set("verified_domain", hostname, {
95-
httpOnly: true,
96-
secure: process.env.NODE_ENV === "production",
97-
sameSite: "strict",
98-
maxAge: 3600, // Cache for 1 hour
99-
});
100-
101-
// Get the pathname and referrer
102-
const { pathname } = request.nextUrl;
103-
const referrer = request.headers.get("referer") || "";
104-
105-
// Parse user agent with the userAgent utility
106-
const ua = userAgent(request);
107-
108-
// Add custom headers to check in generateMetadata
109-
response.headers.set("x-pathname", pathname);
110-
response.headers.set("x-referrer", referrer);
111-
response.headers.set("x-user-agent", JSON.stringify(ua));
112-
113-
return response;
69+
// if (!path.startsWith("/s/")) {
70+
const url = new URL(request.url);
71+
url.hostname = webUrl;
72+
return NextResponse.redirect(url);
73+
// }
74+
75+
// // Check if we have a cached verification
76+
// const verifiedDomain = request.cookies.get("verified_domain");
77+
// if (verifiedDomain?.value === hostname) return NextResponse.next();
78+
79+
// // Query the space with this custom domain
80+
// const [organization] = await db()
81+
// .select()
82+
// .from(organizations)
83+
// .where(eq(organizations.customDomain, hostname));
84+
85+
// if (!organization || !organization.domainVerified) {
86+
// // If no verified custom domain found, redirect to main domain
87+
// const url = new URL(request.url);
88+
// url.hostname = webUrl;
89+
// return NextResponse.redirect(url);
90+
// }
91+
92+
// // Set verification cookie for non-API routes too
93+
// const response = NextResponse.next();
94+
// response.cookies.set("verified_domain", hostname, {
95+
// httpOnly: true,
96+
// secure: process.env.NODE_ENV === "production",
97+
// sameSite: "strict",
98+
// maxAge: 3600, // Cache for 1 hour
99+
// });
100+
101+
// // Get the pathname and referrer
102+
// const { pathname } = request.nextUrl;
103+
// const referrer = request.headers.get("referer") || "";
104+
105+
// // Parse user agent with the userAgent utility
106+
// const ua = userAgent(request);
107+
108+
// // Add custom headers to check in generateMetadata
109+
// response.headers.set("x-pathname", pathname);
110+
// response.headers.set("x-referrer", referrer);
111+
// response.headers.set("x-user-agent", JSON.stringify(ua));
112+
113+
// return response;
114114
} catch (error) {
115115
console.error("Error in middleware:", error);
116116
return notFound();

0 commit comments

Comments
 (0)