Skip to content

Missing useRuntimeConfig values on Lambda #706

@tuan-bui

Description

@tuan-bui

Environment


  • Operating System: Darwin
  • Node Version: v14.21.1
  • Nuxt Version: 2.16.0
  • Nitro Version: 1.0.0
  • Package Manager: yarn@1.22.19
  • Builder: webpack
  • User Config: nitro, router, head, css, plugins, dir, storybook, buildModules, modulesDir, modules, i18n, app, runtimeConfig, publicRuntimeConfig, alias, typescript, build, serverHandlers, devServerHandlers, devServer, bridge
  • Runtime Modules: @nuxtjs/i18n@7.3.1
  • Build Modules: (), @nuxt/bridge@3.0.0-27909973.a4c5d19, @nuxtjs/stylelint-module@4.1.0

Reproduction

  • Reproduction this issue is tricky as it requires Lambda
  • Install the latest Nuxt Bridge version
  • Add a new test endpoint test.get
  • Add a page that calls the endpoint using asyncData
  • Add basic logging into the endpoint before calling useRuntimeConfig:
  console.log(process.env);
  console.log(useRuntimeConfig());
  • Modify the nuxt.config.ts:
runtimeConfig: {
    cmsApiKey: "",
    cmsDeliveryToken: "",
    cmsManagementToken: "",
}
  • Set the NITRO_PRESET environment variable to aws-lambda and build the project
  • Deploy the project to Lambda with the expected values NUXT_CMS_API_KEY, NUXT_CMS_DELIVERY_TOKEN, NUXT_CMS_MANAGEMENT_TOKEN
  • Run the application several times and we can see process.env returns the expected values.useRuntimeConfig returns expected values on the first couple of loads but becomes the default empty values after

Describe the bug

useRuntimeConfig returns the environment variables as expected on the initial load but returns empty values for privateRuntimeVariables after loading the page several times.

Additional context

Current working version: 3.0.0-27498038.f18e68b
Latest version: NOT WORKING

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions