Skip to content

Commit

Permalink
refacto(all): add request logs
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrompier committed May 3, 2024
1 parent 4bc96fb commit 75b2833
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ export const handleError: HandleServerError = async ({ error, event }) => {
};

export const handle: Handle = async ({ event, resolve }) => {
// only allow metrics from localhost if we're not in dev mode
if (
event.url.pathname.startsWith(`${base}/metrics`) &&
!dev &&
event.request.headers.get("host") !== "localhost:3000"
) {
return new Response("Forbidden", { status: 403 });
}
logger.info({
locals: event.locals,
url: event.url.pathname,
params: event.params,
request: event.request,
});

if (event.url.pathname.startsWith(`${base}/api/`) && EXPOSE_API !== "true") {
return new Response("API is disabled", { status: 403 });
Expand Down

0 comments on commit 75b2833

Please sign in to comment.