-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #661 from WestpacGEL/develop
Develop
- Loading branch information
Showing
3 changed files
with
52 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import crypto from 'crypto'; | ||
|
||
import { sql } from '@vercel/postgres'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
export async function POST(request: Request) { | ||
const response = NextResponse.json({}); | ||
// eslint-disable-next-line turbo/no-undeclared-env-vars | ||
response.headers.set('x-vercel-verify', process.env.LOG_DRAIN_VERIFY || ''); | ||
|
||
return response; | ||
// if (process.env.NODE_ENV === 'production') { | ||
// if (typeof process.env.VERCEL_LOG_DRAIN_SECRET != 'string') { | ||
// throw new Error('No integration secret found'); | ||
// } | ||
|
||
// if (!verifySignature(request)) { | ||
// return NextResponse.json({ | ||
// code: 'invalid_signature', | ||
// error: "signature didn't match", | ||
// }); | ||
// } | ||
|
||
// try { | ||
// const logs = await request.json(); | ||
|
||
// for (const log of logs) { | ||
// const { | ||
// id, | ||
// timestamp, | ||
// proxy: { clientIp, referer }, | ||
// } = log; | ||
|
||
// await sql`INSERT INTO logs_drain(log_id, time, request_ip, request_url) VALUES (${id}, TO_TIMESTAMP(${timestamp}::bigint/1000), ${clientIp}, ${referer})`; | ||
// } | ||
// } catch (error) { | ||
// return NextResponse.json({ error }, { status: 500 }); | ||
// } | ||
// } | ||
|
||
// return NextResponse.json({ message: 'Logged successfully' }); | ||
} | ||
|
||
async function verifySignature(request: Request) { | ||
const signature = crypto | ||
.createHmac('sha1', process.env.VERCEL_LOG_DRAIN_SECRET || '') | ||
.update(JSON.stringify(request.body)) | ||
.digest('hex'); | ||
return signature === request.headers.get('x-vercel-signature'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f73c031
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
gel-next-site – ./apps/site
gel-next-site.vercel.app
gel-next-site-westpacgel.vercel.app
gel-next-site-git-main-westpacgel.vercel.app