Tap to unmute

This Vue Mistake Was A Real Problem

  Рет қаралды 3,940

Program With Erik

Program With Erik

Күн бұрын

Пікірлер: 19
@ProgramWithErik
@ProgramWithErik 11 ай бұрын
How would you solve this problem? Also quick shout out to my mailing list! bit.ly/3Umk7sW
@AdamRobertson
@AdamRobertson 11 ай бұрын
You're still doing it a bit wrong. You should simply put a 'default' value in the nuxt.config, e.g. `myPublic: 'foo'`, this will then get automatically overidden if the corresponding env var exists at runtime, or use the given default if not. You don't need to reference `process.env` as long as you follow the naming convention.
@AdamRobertson
@AdamRobertson 11 ай бұрын
this has the nice added benefit of allowing the type to be inferred from the default given, e.g. `myNum: 123` should type `useRuntimeConfig().public.myNum` to a number in your vue file.
@ProgramWithErik
@ProgramWithErik 11 ай бұрын
Nice tip!
@iUmerFarooq
@iUmerFarooq 11 ай бұрын
Make some Backend content of Nuxt 3. And also make Vuejs and Nuxtjs tips in shorts on daily bases if possible!
@MartinMasevski
@MartinMasevski 11 ай бұрын
Went through the same thing and learned the hard way ❤
@ProgramWithErik
@ProgramWithErik 11 ай бұрын
Thanks!
@CabbageShop
@CabbageShop 11 ай бұрын
Interesting, only thing is don't you lose the type inference doing it that way?
@ProgramWithErik
@ProgramWithErik 11 ай бұрын
Yeah I suppose it could, but secrets are usually strings
@yabuking84
@yabuking84 11 ай бұрын
Your env SECRET=somesecret, but on your server console it says process blah. Shouldnt that say process somesecret?
@ProgramWithErik
@ProgramWithErik 11 ай бұрын
It would be process.env.SECRET the variable name
@swildermuth
@swildermuth 11 ай бұрын
Isn't this a Nuxt issue, not a Vue issue?
@ProgramWithErik
@ProgramWithErik 11 ай бұрын
Little of A a little of B
@thedawg666
@thedawg666 11 ай бұрын
VITE not VEET
@ProgramWithErik
@ProgramWithErik 11 ай бұрын
You are wrong
@thedawg666
@thedawg666 11 ай бұрын
@@ProgramWithErik well there you go , ive been calling it vite all along
@Tarabass
@Tarabass 11 ай бұрын
You are doing it wrong! Thereby it's better to delete this video if you ask me. In your nuxt config you put default values. In your env file you overwrite those values using the naming convention NUXT_VAR for private vars or NUXT_PUBLIC_VAR for public vars. Using those vars can be done with useRuntimeConfig() or useRuntimeConfig().public. useRuntimeConfig is the only composable you may use in api endpoints. Bonus, if you want to proxy use proxyRequest in your api endpoint with the secret and endpoint from your vars using useRuntimeConfig instead of routerules - > proxy..
@Joachimbj
@Joachimbj 11 ай бұрын
I went through the exact same steps as he did when figuring out how to do it properly, so it was fun to see that I wasn't alone. I think the video is valueable since he's humble about the approach and the last piece of info about the defaults is in the comments 😊
@Tarabass
@Tarabass 11 ай бұрын
@@Joachimbj true. Maybe some edit that the solution is not in the video. FYI, the naming convention also counts for nitro vars like NITRO_PORT..
Vue 3 Watch vs WatchEffect! Watch OUT, you'll probably get this wrong!
9:05
3 Must Know Tips For Nuxt.js Developers
9:23
Program With Erik
Рет қаралды 10 М.
GIANT Gummy Worm #shorts
0:42
Mr DegrEE
Рет қаралды 152 МЛН
Какой я клей? | CLEX #shorts
0:59
CLEX
Рет қаралды 1,9 МЛН
Coding Shorts: Using the Vite PWA Plug-in
14:05
Shawn Wildermuth
Рет қаралды 29 М.
A Better Way To Create Vue Components With Props Using TypeScript
12:40
Program With Erik
Рет қаралды 10 М.
The Nuxt big thing in web development?
4:55
Fireship
Рет қаралды 662 М.
Get Started With Nuxt's Runtime Config API
12:48
John Komarnicki
Рет қаралды 1,9 М.
What Is Vue 3 Vapor Mode?!
6:38
Program With Erik
Рет қаралды 12 М.
What's New in Vue 3.4
7:43
Laracasts
Рет қаралды 7 М.
What I Learned from State of JS 2024
36:49
Jack Herrington
Рет қаралды 10 М.
Handling Webhooks With Nuxt 3
8:40
John Komarnicki
Рет қаралды 3,9 М.
Why you should use useState()
17:57
Alexander Lichter
Рет қаралды 23 М.