I have added a enviroment variable REACT_THUMBNAIL_URL_PREFIX in .env.client file but i can't use it
I have added a enviroment variable REACT_THUMBNAIL_URL_PREFIX in .env.client file but i can't use it . I have tried import.meta.env.REACT_THUMBNAIL_URL_PREFIX
1 Reply
Hi @XMDim. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The reason you can't access REACT_THUMBNAIL_URL_PREFIX via import.meta.env.REACT_THUMBNAIL_URL_PREFIX is because, in Wasp, client environment variables must be prefixed with REACTAPP in order to be picked up and embedded into the client code. This is a requirement inherited from Create React App, which Wasp currently follows for client env vars.
So, you should rename your variable in .env.client to:
Then, in your client code, you can access it like this:
This will work both in development and production, as long as you follow the REACTAPP prefix convention for client environment variables in Wasp. For more details, see the official documentation: Wasp Docs: Env Variables.
If you use any other prefix (like just REACT_), Wasp will not embed the variable into your client code, and import.meta.env.REACT_THUMBNAIL_URL_PREFIX will be undefined.
Let me know if you need more help!
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @XMDim, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?