mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 14:17:13 +01:00
Link route.
This commit is contained in:
parent
2631fa51da
commit
789b8b36d8
4 changed files with 93 additions and 58 deletions
|
|
@ -0,0 +1,37 @@
|
|||
import { NextResponse } from 'next/server';
|
||||
import { notFound } from '@/lib/response';
|
||||
import { findLink } from '@/queries';
|
||||
import { POST } from '@/app/api/send/route';
|
||||
|
||||
export async function GET(request: Request, { params }: { params: Promise<{ slug: string }> }) {
|
||||
const { slug } = await params;
|
||||
|
||||
const link = await findLink({
|
||||
where: {
|
||||
slug,
|
||||
},
|
||||
});
|
||||
|
||||
if (!link) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
const payload = {
|
||||
type: 'event',
|
||||
payload: {
|
||||
link: link.id,
|
||||
url: request.url,
|
||||
referrer: request.referrer,
|
||||
},
|
||||
};
|
||||
|
||||
const req = new Request(request.url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
await POST(req);
|
||||
|
||||
return NextResponse.redirect(link.url);
|
||||
}
|
||||
|
|
@ -257,9 +257,7 @@ export async function POST(request: Request) {
|
|||
lifatid,
|
||||
twclid,
|
||||
});
|
||||
}
|
||||
|
||||
if (type === COLLECTION_TYPE.identify) {
|
||||
} else if (type === COLLECTION_TYPE.identify) {
|
||||
if (data) {
|
||||
await saveSessionData({
|
||||
websiteId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue