mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Redact URLs before logging
This commit is contained in:
parent
e334df1a88
commit
d0b2c8fd1c
@ -63,11 +63,16 @@ export async function parseRequest<T>(req: NextRequest, schema: yup.Schema<T>):
|
||||
export function smartRouteHandler(handler: (req: NextRequest, options: any) => Promise<Response>): (req: NextRequest, options: any) => Promise<Response> {
|
||||
return async (req: NextRequest, options: any) => {
|
||||
try {
|
||||
console.log(`[API REQ] ${req.method} ${req.url}`);
|
||||
const censoredUrl = new URL(req.url);
|
||||
for (const key of censoredUrl.searchParams.keys()) {
|
||||
censoredUrl.searchParams.set(key, "--REDACTED--");
|
||||
}
|
||||
|
||||
console.log(`[API REQ] ${req.method} ${censoredUrl}`);
|
||||
const timeStart = performance.now();
|
||||
const res = await handler(req, options);
|
||||
const time = (performance.now() - timeStart);
|
||||
console.log(`[ RES] ${req.method} ${req.url} (in ${time.toFixed(0)}ms)`);
|
||||
console.log(`[ RES] ${req.method} ${censoredUrl} (in ${time.toFixed(0)}ms)`);
|
||||
return res;
|
||||
} catch (e) {
|
||||
// catch some Next.js non-errors and rethrow them
|
||||
|
||||
@ -14,8 +14,8 @@ export default function OauthCallback () {
|
||||
if (called.current) return;
|
||||
called.current = true;
|
||||
await app.callOauthCallback();
|
||||
await router.push(app.urls.userHome);
|
||||
router.push(app.urls.userHome);
|
||||
}), []);
|
||||
|
||||
return <MessageCard title='Redirecting...' fullPage />;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user