Skip to content
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

ENV variables in client #2427

Open
saeho opened this issue May 16, 2024 · 5 comments
Open

ENV variables in client #2427

saeho opened this issue May 16, 2024 · 5 comments

Comments

@saeho
Copy link

saeho commented May 16, 2024

So, by now I understood that .env files can only be read on the front-end server because Deno is not available on the client side...

So, now how am I suppose to create secrets for my app or have environment variables or detect if it's in development or production mode on the client side?

I looked everywhere in the docs but couldn't find an answer.

Any help would be appreciated.

@miguelrk
Copy link

IIRC, @marvinhagemeister has argumented against supporting a way to access env variables from the browser/client before, due primarily to security concerns. Currently, you would need to e.g. proxy requests via a server route/endpoint which injects these. Other full-stack frameworks do support exposing certain env variables to the client, and I think they are indeed valid use cases for this, but don't think it's in scope for Fresh 2.0.

@saeho
Copy link
Author

saeho commented May 16, 2024

gotcha. since client side is never secure anyways, I think this is fine.

@saeho
Copy link
Author

saeho commented May 16, 2024

one more question. how do I jumble/minify my development app/production deployment so the code and CSS cannot be human-read easily?

@marvinhagemeister
Copy link
Collaborator

JS code is automatically minifed in Fresh. Note that obfuscation is never an adequate security measure. If you are worried about leaking sensitive code, you should never sent it to the browser in the first place.

@saeho
Copy link
Author

saeho commented May 16, 2024

Not worried about leaking sensitive code. I'm more worried about people using front-end scripting to hack the web socket. I'm making a new app and it happened before in my other app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants