Skip to content

Failed to load .env file #3163

Closed Answered by wiseaidev
abhi3700 asked this question in Q&A
Nov 2, 2024 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

You can access these env vars on the server (e.g., Axum) when using Dioxus full-stack, but not on the client side (Dioxus Web) in the browser. I had the same question while building this full-stack blog app. I needed a way to set the admin email and password in the environment variables. Then I realized I could check the user's role for login, setting it to 'admin' by manually updating the role in MongoDB from the default 'user' to 'admin.'

Edit: dotenv sets env vars at runtime and can't be accessed from WASM env. Try using the std::env macro to access these env vars at compile time, wasm.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@abhi3700
Comment options

@wiseaidev
Comment options

Answer selected by abhi3700
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants