aboutsummaryrefslogtreecommitdiff
path: root/communities/174bg/174bg.net/src/proxy.js
diff options
context:
space:
mode:
authorAlex Pooley (@zuedev) <zuedev@gmail.com>2026-05-24 12:58:49 +0100
committerAlex Pooley (@zuedev) <zuedev@gmail.com>2026-05-24 12:58:49 +0100
commite2066f51523ecba0f1991edd0c2b94f8f4cd1820 (patch)
tree8aedfff6c5d321d612278b40002a8e8037105b08 /communities/174bg/174bg.net/src/proxy.js
parent7bcfcc53b2dcbfb6efc82524f7bd078b716fd27b (diff)
downloadunnamed-group-e2066f51523ecba0f1991edd0c2b94f8f4cd1820.tar
unnamed-group-e2066f51523ecba0f1991edd0c2b94f8f4cd1820.tar.gz
unnamed-group-e2066f51523ecba0f1991edd0c2b94f8f4cd1820.tar.bz2
unnamed-group-e2066f51523ecba0f1991edd0c2b94f8f4cd1820.tar.xz
unnamed-group-e2066f51523ecba0f1991edd0c2b94f8f4cd1820.zip
shorten community subdirs
Diffstat (limited to 'communities/174bg/174bg.net/src/proxy.js')
-rw-r--r--communities/174bg/174bg.net/src/proxy.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/communities/174bg/174bg.net/src/proxy.js b/communities/174bg/174bg.net/src/proxy.js
new file mode 100644
index 0000000..dc0fa42
--- /dev/null
+++ b/communities/174bg/174bg.net/src/proxy.js
@@ -0,0 +1,30 @@
+import { NextResponse } from "next/server";
+
+export async function proxy(request) {
+ let session = null;
+
+ try {
+ const internalUrl =
+ process.env.BETTER_AUTH_URL_INTERNAL || "http://localhost:3000";
+ const res = await fetch(new URL("/api/auth/get-session", internalUrl), {
+ headers: {
+ cookie: request.headers.get("cookie") ?? "",
+ },
+ });
+ session = await res.json();
+ } catch {
+ // If session check fails, treat as unauthenticated
+ }
+
+ if (!session?.user) {
+ const loginUrl = new URL("/login", request.url);
+ loginUrl.searchParams.set("callbackUrl", request.nextUrl.pathname);
+ return NextResponse.redirect(loginUrl);
+ }
+
+ return NextResponse.next();
+}
+
+export const config = {
+ matcher: ["/secure/:path*"],
+};