t3-oss / t3-env

https://env.t3.gg
MIT License
2.45k stars 79 forks source link

Can't explicitly pass `clientPrefix` option using `nuxt` #198

Closed dammy001 closed 4 months ago

dammy001 commented 4 months ago
import { createEnv } from '@t3-oss/env-nuxt'
import { z } from '@bunce/schema'

export const env = createEnv({
  clientPrefix: 'NUXT_',

  client: {
    NUXT_BASE_URL: z.string().min(1),
  },
  runtimeEnv: process.env,
})

This always make use of the default NUXT_PUBLIC_

juliusmarminge commented 4 months ago

afaik NUXT_FOO isn't populated on client but you need to do NUXT_PUBLIC_FOO, hence the pre-configured client prefix of NUXT_PUBLIC_.

dammy001 commented 4 months ago

@juliusmarminge What if I don't want to add PUBLIC_? I just need NUXT_. This option clientPrefix should be exposed on userland.

juliusmarminge commented 4 months ago

I dont think you understand what clientPrefix means. It's the thing you prefix your variabler with if you want the value sent to client. NUXT_ doesnt do that, NUXTPUBLIC does.

dammy001 commented 4 months ago

@juliusmarminge Currently, without using t3-env my environment variables are prefixed with NUXT_ without adding PUBLIC_, and it works fine, but adding this package will result in me changing my environment variables, which I really don't want to do.

dammy001 commented 4 months ago

@juliusmarminge i get your point now

juliusmarminge commented 4 months ago

Currently, without using t3-env my environment variables are prefixed with NUXT without adding PUBLIC, and it works fine

Then those should go in the server object