Add ability to do debug logging with REQ_DEBUG=true

This commit is contained in:
mrjvs 2024-01-06 18:44:06 +01:00
parent ad0ae4aaae
commit 5faca36cb4
2 changed files with 10 additions and 2 deletions

View File

@ -6,7 +6,7 @@ export default defineNitroConfig({
noPublicDir: true,
srcDir: "./src",
runtimeConfig: {
version: pkg.version,
version: pkg.version
},
alias: {
"@": join(__dirname, "src")

View File

@ -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,