mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
Mask headers when logged and dont log request body in production
This commit is contained in:
parent
93b35428ce
commit
c166eef63c
3 changed files with 14 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="cf-api (dev)" type="js.build_tools.npm">
|
||||
<configuration default="false" name="cf-api (dev github app)" type="js.build_tools.npm">
|
||||
<package-json value="$PROJECT_DIR$/js/cf-api/package.json" />
|
||||
<command value="run" />
|
||||
<scripts>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="cf-api (prod)" type="js.build_tools.npm">
|
||||
<configuration default="false" name="cf-api (prod github app)" type="js.build_tools.npm">
|
||||
<package-json value="$PROJECT_DIR$/js/cf-api/package.json" />
|
||||
<command value="run" />
|
||||
<scripts>
|
||||
|
|
@ -29,7 +29,11 @@ const appExpress = express()
|
|||
|
||||
appExpress.use((req, res, next) => {
|
||||
console.log(`<<< Received ${req.method} request for ${req.url}`)
|
||||
console.log(`<<< Request headers: ${JSON.stringify(req.headers)}`)
|
||||
const maskedHeaders = {
|
||||
...req.headers,
|
||||
authorization: req.headers.authorization?.replace(/(Bearer\s)cf-(.*)(.{4})/, "$1cf-****$3"),
|
||||
}
|
||||
console.log(`<<< Request headers: ${JSON.stringify(maskedHeaders)}`)
|
||||
console.log(`<<< Request params: ${JSON.stringify(req.params)}`)
|
||||
console.log(`<<< Request query: ${JSON.stringify(req.query)}`)
|
||||
next()
|
||||
|
|
@ -48,10 +52,13 @@ appExpress.post(`${ghAppPathPrefix}/webhooks`, async (req, res) => {
|
|||
// MUST be after github webhook middleware
|
||||
appExpress.use(express.json({ limit: "10mb" }))
|
||||
|
||||
appExpress.use((req, res, next) => {
|
||||
console.log(`<<< Request body: ${JSON.stringify(req.body)}`)
|
||||
next()
|
||||
})
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
// Log request body for debugging purposes
|
||||
appExpress.use((req, res, next) => {
|
||||
console.log(`<<< Request body: ${JSON.stringify(req.body)}`)
|
||||
next()
|
||||
})
|
||||
}
|
||||
|
||||
appExpress.get("/", async (req, res) => {
|
||||
return res.status(200).send("OK")
|
||||
|
|
|
|||
Loading…
Reference in a new issue