Skip to content

Commit 13e53a4

Browse files
authored
fix: if --debug, enable debug logging for edge functions (#5367)
1 parent 85b98aa commit 13e53a4

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

src/commands/dev/dev.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ const dev = async (options, command) => {
163163
addonsUrls,
164164
config,
165165
configPath: configPathOverride,
166+
debug: options.debug,
166167
env,
167168
geolocationMode: options.geo,
168169
geoCountry: options.country,

src/lib/edge-functions/headers.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const headers = {
77
RequestID: 'X-NF-Request-ID',
88
IP: 'x-nf-client-connection-ip',
99
Site: 'X-NF-Site-Info',
10+
DebugLogging: 'x-nf-debug-logging',
1011
}
1112

1213
export default headers

src/lib/edge-functions/proxy.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const createSiteInfoHeader = (siteInfo = {}) => {
5656
export const initializeProxy = async ({
5757
config,
5858
configPath,
59+
debug,
5960
env: configEnv,
6061
geoCountry,
6162
geolocationMode,
@@ -137,6 +138,10 @@ export const initializeProxy = async ({
137138
[headers.IP]: LOCAL_HOST,
138139
}
139140

141+
if (debug) {
142+
req[headersSymbol][headers.DebugLogging] = '1'
143+
}
144+
140145
if (settings.https) {
141146
req[headersSymbol][headers.ForwardedProtocol] = 'https'
142147
}

src/utils/proxy-server.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const generateInspectSettings = (edgeInspect, edgeInspectBrk) => {
3939
* @param {*} params.addonsUrls
4040
* @param {import('../commands/base-command.mjs').NetlifyOptions["config"]} params.config
4141
* @param {string} [params.configPath] An override for the Netlify config path
42+
* @param {boolean} params.debug
4243
* @param {import('../commands/base-command.mjs').NetlifyOptions["cachedConfig"]['env']} params.env
4344
* @param {InspectSettings} params.inspectSettings
4445
* @param {() => Promise<object>} params.getUpdatedConfig
@@ -55,6 +56,7 @@ export const startProxyServer = async ({
5556
addonsUrls,
5657
config,
5758
configPath,
59+
debug,
5860
env,
5961
geoCountry,
6062
geolocationMode,
@@ -70,6 +72,7 @@ export const startProxyServer = async ({
7072
addonsUrls,
7173
config,
7274
configPath: configPath || site.configPath,
75+
debug,
7376
env,
7477
geolocationMode,
7578
geoCountry,

src/utils/proxy.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ export const startProxy = async function ({
533533
addonsUrls,
534534
config,
535535
configPath,
536+
debug,
536537
env,
537538
geoCountry,
538539
geolocationMode,
@@ -548,6 +549,7 @@ export const startProxy = async function ({
548549
const edgeFunctionsProxy = await initializeEdgeFunctionsProxy({
549550
config,
550551
configPath,
552+
debug,
551553
env,
552554
geolocationMode,
553555
geoCountry,

0 commit comments

Comments
 (0)