<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/why-client-side-environment-variables-are-a-bad-idea-iiqo4t67k" -->

---
title: why client-side environment variables are a bad idea
description: Discusses the potential dangers and security risks associated with using client-side environment variables for storing sensitive information, illustrated...
canonical: https://daily.dev/posts/why-client-side-environment-variables-are-a-bad-idea-iiqo4t67k
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: why client-side environment variables are a bad idea | daily.dev
og:description: Discusses the potential dangers and security risks associated with using client-side environment variables for storing sensitive information, illustrated...
og:url: https://daily.dev/posts/why-client-side-environment-variables-are-a-bad-idea-iiqo4t67k
og:image: https://api.daily.dev/og/posts/IIqo4T67k.png
og:image:alt: why client-side environment variables are a bad idea
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# why client-side environment variables are a bad idea

**[Community Picks](https://daily.dev/sources/community)** · 4 min read · 67 upvotes · 7 comments

## Summary

Discusses the potential dangers and security risks associated with using client-side environment variables for storing sensitive information, illustrated through a specific case involving Gamersafer. Through detailed recounting of how AWS keys were exposed and the implications thereof, it underscores the importance of server-side API calls for handling sensitive data.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.kibty.town/blog/gamersafer/>

## Community discussion

Top comments from developers on daily.dev.

**@jsnelders** · 13 upvotes

> TL;DR: don't expose 3rd party access keys (AWS secrets, in this case) in the browser. They must stay on the server-side of web applications.
>
> For clarification, the "client-side environment variables" mentioned in this article actually seem to be values in plain JavaScript objects, sent from the server (but should be kept on the server) and viewable in source. I think. It's a difficult article to parse.
>
> Kudos to the author for their investigation.
>
> But, just an old man gripe: if you're going to write an article in a human language (English in this case) for the world to read, learn and use...

**@hydranapse\_** · 0 upvotes

> Solution if you want to upload via frontend: https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html

**@fabooy961** · 0 upvotes

> isn't this obvious and if you fall for that, you should quit your dev job and go for janitor or smth?

---

Tags: [#security](https://daily.dev/tags/security), [#webdev](https://daily.dev/tags/webdev), [#javascript](https://daily.dev/tags/javascript), [#aws](https://daily.dev/tags/aws)

[View this post on daily.dev](https://daily.dev/posts/why-client-side-environment-variables-are-a-bad-idea-iiqo4t67k)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"why client-side environment variables are a bad idea","url":"https://daily.dev/posts/why-client-side-environment-variables-are-a-bad-idea-iiqo4t67k","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/why-client-side-environment-variables-are-a-bad-idea-iiqo4t67k"},"datePublished":"2024-10-14T10:41:53.989Z","dateModified":"2024-12-12T09:03:29.034Z","description":"Discusses the potential dangers and security risks associated with using client-side environment variables for storing sensitive information, illustrated...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3367efb2717bfea080a13276de07cd84?_a=AQAEuiZ","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3367efb2717bfea080a13276de07cd84?_a=AQAEuiZ","isAccessibleForFree":true,"articleSection":"Community Picks","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Community Picks","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1655817725/logos/community","url":"https://daily.dev/sources/community"},"commentCount":7,"discussionUrl":"https://daily.dev/posts/why-client-side-environment-variables-are-a-bad-idea-iiqo4t67k","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":67},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":7}],"keywords":"security,webdev,javascript,aws","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Community Picks","item":"https://daily.dev/sources/community"},{"@type":"ListItem","position":3,"name":"why client-side environment variables are a bad idea"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/why-client-side-environment-variables-are-a-bad-idea-iiqo4t67k","comment":[{"@type":"Comment","text":"TL;DR: don’t expose 3rd party access keys (AWS secrets, in this case) in the browser. They must stay on the server-side of web applications.\nFor clarification, the “client-side environment variables” mentioned in this article actually seem to be values in plain JavaScript objects, sent from the server (but should be kept on the server) and viewable in source. I think. It’s a difficult article to parse.\nKudos to the author for their investigation.\nBut, just an old man gripe: if you’re going to write an article in a human language (English in this case) for the world to read, learn and use the f-ing grammar of the language. At the very least learn how to capitalise. Otherwise you look like an uneducated and lazy child. Have some care in communication, and respect your readers.","datePublished":"2024-10-15T02:47:03.085Z","url":"https://daily.dev/posts/IIqo4T67k#c-AdN5iCW31","author":{"@type":"Person","name":"Jason","url":"https://daily.dev/jsnelders","image":"https://media.daily.dev/image/upload/s--O0TOmw4y--/f_auto/v1715772965/public/noProfile"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":13}},{"@type":"Comment","text":"Solution if you want to upload via frontend: https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html","datePublished":"2024-10-30T01:54:52.835Z","url":"https://daily.dev/posts/IIqo4T67k#c-xrNDR3li0","author":{"@type":"Person","name":"Hydranapse_T","url":"https://daily.dev/hydranapse_","image":"https://lh3.googleusercontent.com/a/ACg8ocL7UIT4o8ygjlDGLJsIiRZ4bfLv4VcKfF5SF0EgeOWfKhBQA3VF=s96-c"}},{"@type":"Comment","text":"isn’t this obvious and if you fall for that, you should quit your dev job and go for janitor or smth?","datePublished":"2024-11-14T12:26:41.475Z","url":"https://daily.dev/posts/IIqo4T67k#c-NrZs13SMx","author":{"@type":"Person","name":"Le Fä De Le Lö","url":"https://daily.dev/fabooy961","image":"https://media.daily.dev/image/upload/v1677218265/avatars/avatar_H6lLM2y9S4Yf8VCWicpd8.jpg"}}]}
```

