Skip to content

Commit

Permalink
Add ability to do debug logging with REQ_DEBUG=true
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjvs committed Jan 6, 2024
1 parent ad0ae4a commit 5faca36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nitro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default defineNitroConfig({
noPublicDir: true,
srcDir: "./src",
runtimeConfig: {
version: pkg.version,
version: pkg.version
},
alias: {
"@": join(__dirname, "src")
Expand Down
10 changes: 9 additions & 1 deletion src/utils/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ export async function specificProxyRequest(
opts.fetchOptions?.headers,
opts.headers,
);
(fetchHeaders.forEach as any)(console.log);
const headerObj = Object.fromEntries([...(fetchHeaders.entries as any)()]);
if (process.env.REQ_DEBUG === 'true') {
console.log({
type: 'request',
method,
url: target,
headers: headerObj,
});
}

return sendProxy(event, target, {
...opts,
Expand Down

0 comments on commit 5faca36

Please sign in to comment.