Skip to content

Commit 198c515

Browse files
TemaDeveloperclaude
andcommitted
chore(domain): build share links from the request origin (domain-agnostic)
Share invite links now derive from the request's host (honouring x-forwarded-host/proto), falling back to NEXTAUTH_URL, so they're correct on lifora.space (or any domain) without depending on an env var. Prod NEXTAUTH_URL/AUTH_URL were also set to https://lifora.space. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ddca4cd commit 198c515

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/app/api/shares/route.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ export async function POST(req: NextRequest) {
4747
label: label ?? "",
4848
});
4949

50-
const url = `${process.env.NEXTAUTH_URL || "http://localhost:3000"}/shared/${token}`;
50+
// Build the share link from the request's own origin so it's correct on any
51+
// domain (e.g. lifora.space), honouring proxy headers, then fall back to env.
52+
const fwdHost = req.headers.get("x-forwarded-host") ?? req.headers.get("host");
53+
const fwdProto = req.headers.get("x-forwarded-proto") ?? "https";
54+
const origin = fwdHost ? `${fwdProto}://${fwdHost}` : (process.env.NEXTAUTH_URL || "http://localhost:3000");
55+
const url = `${origin}/shared/${token}`;
5156

5257
if (inviteeEmail) {
5358
const owner = await User.findById(userId).lean();

0 commit comments

Comments
 (0)