Skip to content

Commit ba65a56

Browse files
committed
chore(graph): set env var before the launcher
1 parent daa0d3c commit ba65a56

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/runtime/src/templates/getHandler.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ const makeHandler = (conf: NextConfig, app, pageRoot, staticManifest: Array<[str
101101
const query = new URLSearchParams(event.queryStringParameters).toString()
102102
event.path = query ? `${event.path}?${query}` : event.path
103103

104+
const graphToken = event.netlifyGraphToken
105+
if (graphToken && requestMode !== 'ssr') {
106+
// Prefix with underscore to help us determine the origin of the token
107+
// allows us to write better error messages
108+
// eslint-disable-next-line no-underscore-dangle
109+
process.env._NETLIFY_GRAPH_TOKEN = graphToken
110+
}
111+
104112
const { headers, ...result } = await getBridge(event).launcher(event, context)
105113

106114
// Convert all headers to multiValueHeaders
@@ -131,14 +139,6 @@ const makeHandler = (conf: NextConfig, app, pageRoot, staticManifest: Array<[str
131139
`[${event.httpMethod}] ${event.path} (${requestMode?.toUpperCase()}${result.ttl > 0 ? ` ${result.ttl}s` : ''})`,
132140
)
133141

134-
const graphToken = event.netlifyGraphToken
135-
if (graphToken && requestMode !== 'ssr') {
136-
// Prefix with underscore to help us determine the origin of the token
137-
// allows us to write better error messages
138-
// eslint-disable-next-line no-underscore-dangle
139-
process.env._NETLIFY_GRAPH_TOKEN = graphToken
140-
}
141-
142142
return {
143143
...result,
144144
multiValueHeaders,

0 commit comments

Comments
 (0)