Комментарии:
First
ОтветитьIf im doing Client Side Rendering, how can I prevent exposing my URL in network tab while making requests
Ответитьlol he says the last words so weirdly
ОтветитьI have follows tons of tutorials and lots of reading. As always, you answered all my questions! Thanks a lot!
Ответитьthanks so much!!
Ответитьoh man thank you,
hello from brazil xD
Why can't we do object destructuring with process.env
ОтветитьVERY NICE!
ОтветитьTHANKS
ОтветитьThank you good sir!
ОтветитьNo words about ENV variables for production.
Ответитьthanks
Ответить.env.local does not work for me
ОтветитьThis is so incomplete. Why nothing about different environment files. That's the whole point.
ОтветитьI LOVE U INDIAN MAN
ОтветитьSuper annoyed. I've followed the docs and multiple videos and my public env variables is still returning undefined...
ОтветитьThis video is outdated. Here is what you need to do
1. Create an .env file (just .env no need for .local)
2. Install dotenv module (npm install dotenv)
3. Open next.config.js
4. Copy and paste the following code
/** @type {import('next').NextConfig} */
const fs = require('fs');
const dotenv = require('dotenv');
const env = dotenv.parse(fs.readFileSync('.env'));
const nextConfig = {
reactStrictMode: true,
env: env
}
module.exports = nextConfig
I love you too! 🤪
ОтветитьAllowe you too man
ОтветитьTo anyone struggling out there trying to get these .env variables to work and you are using as of this time version 13.*.*, what is shown here does not work. You WILL need to to the following:
Add .env.* to your .gitignore file.
Create the .env.local file
Add your variable prefixed with NEXT_PUBLIC_
If you do not do this, you cannot see these variables locally via the client. All variables without the NEXT_PUBLIC_ prefix will be available server side ONLY. They reference this in the docs from Next.js but they don't explain it very well. I struggled with this for about 30 minutes before I figured it out.
Hi! I need help with something :( Everyone at work can put their .env file under utils map but mine doesn't load unless I put it in the root dir
Do you have any idea why? :o Ty!
I wasted 2 days figuring out exactly why isn't my environment variables aren't showing and now realize that all I have to do was to include NEXT_PUBLIC next to it. Thank you
ОтветитьShowing undefined
I am using nextjs 13.5
Great tutorial. Simple, clear, and concise. Thank you!
Ответить