-
Notifications
You must be signed in to change notification settings - Fork 9
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
[HELP] Problem accessing env vars in ts #17
Comments
Hello @ssb-jnk, Is your project open source? If so, I can take a direct look. Otherwise, we can schedule a quick call to resolve this issue. Given that you are from Statistics Norway, you are entitled to special treatment. :) |
@garronej Thank you for responding so quickly! I'll gladly accept any VIP treatment! The repository is set to internal, but will at some point be public, there is not any sensitive information in the repository. I have given you read access to the repository. Link directly to the branch containing everything related to vite-envs. Any help is greatly appreciated, thanks! Could also set up a call if that would be easier. |
Here you go:
RUN npm install --save-exact express vite-express
- && cp -r dist/* .
ENV PORT=8080
EXPOSE 8080
-ENTRYPOINT ["sh", "-c", "./vite-envs.sh && npm run prod"]
+ENTRYPOINT ["sh", "-c", "./dist/vite-envs.sh && npm run prod"] Best |
Thank you for the response @garronej! And yes this solved the problem. I tried it earlier but i got a token error where it pointed to the data in the base64 key value map, but your response made me look more into it! Looks like it doesnt like the length of the values. I tried shortening ADMIN_GROUPS, then it worked, and then i tried adding more letters to another env var, and then it caused invalid token error
Looking more into it, it forced a new line in the middle of a value in index.html, because its too long, or something else? Thank you so much! :) |
@ssb-jnk, Sould be fixed in the last release. Let me know if there are any remaining issues. Best |
Greetings!
I am having an issue using vite-envs. I have followed the starter guide to get everything up and running, and it does seem like things do happen behind the scenes, such as index.html including environment variables from --env in docker run. But when i try to access the variabels with
import.meta.env.A
, then its undefined or empty rather.I have a server.js which runs ViteExpress and serves as the apps BFF, and then using nodemon to run it in prod.
Vite-envs version
"vite-envs": "^4.0.13"
I have tried logging what import.meta.env contains, and it does contain the variables but not the values themselves, values are empty, even though the values are visible in index.html (i know this because i decoded the base64 to verify the values).
Variables are defined in .env (empty because i want to set it with docker):
Dockerfile:
I run it like this
Response in console when printing import.meta.env
index.html in the docker container when app is running
Do you have any idea to what might be wrong? Feels like i hit a plateau, so any help would be greatly appreciated
The text was updated successfully, but these errors were encountered: