Atinux / nuxt-env-repro

Minimal reproduction for env issue with CF Pages

Home Page:https://nuxt-env-repro.nuxt.dev/api/env

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nuxt Minimal Reproduction for Env

// nuxt.config.ts
export default defineNuxtConfig({
  runtimeConfig: {
    hello: ''
  }
})
// server/api/env.ts
export default eventHandler(event => {
  const runtimeConfig = useRuntimeConfig(event)

  return {
    'runtimeConfig().hello': useRuntimeConfig().hello,
    'runtimeConfig(event).hello': runtimeConfig.hello,
    'i.meta.env.NUXT_HELLO': import.meta.env.NUXT_HELLO,
    'process.env.NUXT_HELLO': process.env.NUXT_HELLO
  }
})

See https://nuxt-env-repro.nuxt.dev/api/env

Locally, we have on http://localhost:3000/api/env

{
  "runtimeConfig().hello": "world",
  "runtimeConfig(event).hello": "world",
  "i.meta.env.NUXT_HELLO": "world",
  "process.env.NUXT_HELLO": "world"
}

Setup

Make sure to install the dependencies:

bun install

Development Server

Start the development server on http://localhost:3000:

bun run dev

About

Minimal reproduction for env issue with CF Pages

https://nuxt-env-repro.nuxt.dev/api/env


Languages

Language:TypeScript 90.7%Language:Vue 9.3%