Hi,
I run into issue when do netlify build for my yarn project. It seems when bundling edge function, the build is not able to read in the environmental variables. I already imported the environmental variable through netlify env:import .env
the place all my edge function are nextjs api which are configured with runtime “edge” and consumes the env variables like the following.
export const env = {
UPSTASH_REDIS_REST_URL:
process.env.UPSTASH_REDIS_REST_URL ??
Deno.env.get('UPSTASH_REDIS_REST_URL'),
UPSTASH_REDIS_REST_TOKEN:
process.env.UPSTASH_REDIS_REST_TOKEN ??
Deno.env.get('UPSTASH_REDIS_REST_TOKEN'),
};
Howerver, it seems the netlify build still spits error when bundling edge functions and i double checked and it seems due to an undefined env variable should obtained from the above object.
`
Packaging Edge Functions from .netlify/edge-functions directory:
- next_pages_api_chat__convid_
- next_pages_api_store
- next_pages_api_user
- next_src_middleware
TypeError: Cannot read properties of undefined (reading ‘startsWith’)
at new t3 (file:///home/tsla/dev/playground/pdf/language_gpt/frontend/apps/chatyourdocs_app/.netlify/edge-functions/next_pages_api_chat__convid_/bundle.js:280:61657)
at Object.6863 (file:///home/tsla/dev/playground/pdf/language_gpt/frontend/apps/chatyourdocs_app/.netlify/edge-functions/next_pages_api_chat__convid_/bundle.js:280:62973)
at webpack_require (file:///home/tsla/dev/playground/pdf/language_gpt/frontend/apps/chatyourdocs_app/.netlify/edge-functions/next_pages_api_chat__convid_/bundle.js:106:42)
at Object.3177 (file:///home/tsla/dev/playground/pdf/language_gpt/frontend/apps/chatyourdocs_app/.netlify/edge-functions/next_pages_api_chat__convid_/bundle.js:280:524)
at webpack_require (file:///home/tsla/dev/playground/pdf/language_gpt/frontend/apps/chatyourdocs_app/.netlify/edge-functions/next_pages_api_chat__convid_/bundle.js:106:42)
at Object.7218 (file:///home/tsla/dev/playground/pdf/language_gpt/frontend/apps/chatyourdocs_app/.netlify/edge-functions/next_pages_api_chat__convid_/bundle.js:280:64098)
at webpack_require (file:///home/tsla/dev/playground/pdf/language_gpt/frontend/apps/chatyourdocs_app/.netlify/edge-functions/next_pages_api_chat__convid_/bundle.js:106:42)
at Object.1685 (file:///home/tsla/dev/playground/pdf/language_gpt/frontend/apps/chatyourdocs_app/.netlify/edge-functions/next_pages_api_chat__convid_/bundle.js:280:218)
at webpack_require (file:///home/tsla/dev/playground/pdf/language_gpt/frontend/apps/chatyourdocs_app/.netlify/edge-functions/next_pages_api_chat__convid_/bundle.js:106:42)
at file:///home/tsla/dev/playground/pdf/language_gpt/frontend/apps/chatyourdocs_app/.netlify/edge-functions/next_pages_api_chat__convid_/bundle.js:292:11293
Bundling of edge function failed
`