supermemory/apps/web/middleware.ts
MaheshtheDev 5258cb74c8 chore(web): reduce the app to a redirect shell, drop the browser extension (#1651)
chore(web): reduce the app to a redirect shell, drop the browser extension

app.supermemory.ai now forwards everything to the console: plugin, OAuth and invite paths get an immediate 308 with the query intact, everything else shows a short notice first. Removes the browser extension workspace.

chore(web): give the moved notice a proper design

Hostnames become the headline, one primary action, a draining line for the countdown, DM Sans and the dot-grid backdrop from the brand.

chore(docs): point docs and README at the console, drop stale sections

Docs and both READMEs now link to console.supermemory.ai for API keys. Removed the company-brain docs tab with a redirect, and trimmed the README app section.

chore(web): give the redirect five seconds
2026-09-07 19:56:46 +00:00

39 lines
1.4 KiB
TypeScript

import { type NextRequest, NextResponse } from "next/server"
import { consoleOrigin } from "./console-origin"
const RENAMED_PATHS = new Map([
["/auth/connect", "/auth/connect"],
["/auth/agent-connect", "/auth/connect"],
])
const SAME_PATHS = ["/login", "/oauth/consent", "/org/invite/"]
// Machine callers (plugins, OAuth clients, invites) get an instant 308 with the query intact; humans get the notice page.
export default function proxy(request: NextRequest) {
const url = request.nextUrl
const forwarded =
process.env.NODE_ENV !== "production"
? request.headers.get("x-forwarded-host")
: null
const console = consoleOrigin(forwarded ?? url.hostname, url.protocol)
const renamed = RENAMED_PATHS.get(url.pathname)
const same = SAME_PATHS.some(
(p) => url.pathname === p || url.pathname.startsWith(p),
)
const target = renamed ?? (same ? url.pathname : null)
if (target) {
return NextResponse.redirect(`${console}${target}${url.search}`, 308)
}
if (url.pathname !== "/") {
return NextResponse.rewrite(new URL("/", url))
}
return NextResponse.next()
}
export const config = {
matcher: [
"/((?!_next/static|_next/image|favicon.ico|favicon-16x16.png|favicon-32x32.png|apple-touch-icon.png|android-chrome-192x192.png|android-chrome-512x512.png|site.webmanifest|OG.png|logo-fullmark.svg|logo-light-fullmark.svg|icon.png|opengraph-image.png).*)",
],
}