-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Env variables not working on Cloudflare Pages #26215
Comments
Same issue as #25047 (comment) ^ let me know if this works for you. |
@Amar-Gill I tried changing my runtimeConfig: {
public: {
exampleValue: process.env.NUXT_PUBLIC_EXAMPLE_VALUE || "unknown"
}
}, |
@matt-clegg can you try with just runtimeConfig: {
public: {
exampleValue: process.env.NUXT_PUBLIC_EXAMPLE_VALUE
}
}, |
@Amar-Gill I forgot about that! I spotted this video on runtime config. I fixed the nuxt.config.ts file moved the default value into the app.vue file and it's still not being picked up. runtimeConfig: {
public: {
exampleValue: process.env.NUXT_PUBLIC_EXAMPLE_VALUE
}
}, <template>
<div>
<strong>Config:</strong>
<pre>{{ config.public.exampleValue || "No value" }}</pre>
</div>
</template>
<script setup lang="ts">
const config = useRuntimeConfig();
</script> |
This was already resolved in #26058 and should be present in the next release. |
Environment
Reproduction
The reproduction is increadibly simple. Create a new Nuxt app with
pnpm dlx nuxi@latest init <project-name>
.nuxt.config.ts
app.vue
Build the Nuxt app with
nuxt build
then deploy it to Cloudflare usingpnpm dlx wrangler pages deploy dist/
.Describe the bug
When the Nuxt app is deployed to Cloudflare Pages using the
cloudflare-pages
nitro preset, environment variables aren't passed down into Nuxt. Unless I've missed a step in configuring the Nuxt app or something else in Cloudflare, I would expect thepublic.exampleValue
to be overridden with my environment value.The hosted Nuxt app can be found here: https://pages-env-demo-55q.pages.dev/
My environment variable in Cloudflare Pages are configured like so:
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: