@@ -8,16 +8,15 @@ description:
88## What are secrets?
99
1010Secrets are used to hide sensitive information in your application that you
11- don't want the world to see, and are implemented in CodeSandbox using
12- environment variables. The most common use case for using secrets is with API
13- keys.
11+ don't want the world to see, like passwords and API keys. They're implemented in CodeSandbox using
12+ environment variables.
1413
15- Secrets values will not be transferred between forks and ** can only be used in
14+ Secrets are not be transferred between forks and ** can only be used in
1615container sandboxes** .
1716
18- ## Adding secrets in CodeSandbox
17+ ## Adding secrets
1918
20- You can control the secrets in your Server Control Panel, before adding any it
19+ You can add secrets in a container sandbox from the Server Control Panel. Before adding any, it
2120should look like this:
2221
2322![ No Secrets] ( ./images/secrets-1.png )
@@ -26,49 +25,33 @@ Let's say you want to add a Google Maps API key. You can do it like so:
2625
2726![ Map Secrets] ( ./images/secrets-2.png )
2827
29- Pro tip: It's always a good practice to name your secrets all in uppercase.
28+ Pro tip: It's good practice to name your secrets all in uppercase.
3029
31- After clicking the "Save Secret" button the secret is added, the sandbox is
30+ After clicking the "Add Secret" button the secret is added, the sandbox is
3231restarted, and you can see the list of all your secrets above the form.
3332
3433![ Secrets] ( ./images/secrets-3.png )
3534
36- As said earlier, secrets are environment variables, meaning they are defined on
35+ Secrets are environment variables, meaning they are defined on
3736` process.env ` . In the example above, we can read the API key from
38- ` process.env.GOOGLE_MAPS_API_KEY ` .
37+ ` process.env.GOOGLE_MAPS_API_KEY ` . See the example below, showing how to access secrets in your server-side code.
3938
40- Like so:
39+ <iframe
40+ src="https://codesandbox.io/embed/broken-resonance-35lyl?codemirror=1&fontsize=14&hidenavigation=1&theme=dark"
41+ style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
42+ title="broken-resonance-35lyl"
43+ allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
44+ sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
45+ > </iframe >
4146
42- ``` js
43- var http = require (' http' );
47+ ## Editing secrets
4448
45- const key = process .env .GOOGLE_MAPS_API_KEY ;
46-
47- http
48- .createServer (function (req , res ) {
49- res .write (' This your maps key' + key);
50- res .end (); // end the response
51- })
52- .listen (8080 );
53- ```
54-
55- The sandbox used is
56- [ https://codesandbox.io/s/2v6xq474kj ] ( https://codesandbox.io/s/2v6xq474kj )
57-
58- ## Editing secrets in CodeSandbox
59-
60- Our UI also gives you the option to edit or even remove a secret, by hovering
61- the secret you want to edit you will see these two icons:
49+ You can edit and remove existing secrets. Click on the pencil to edit the name and value of your secret:
6250
6351![ Icons] ( ./images/secrets-4.png )
6452
65- If you click on the pencil you will see it will turn into a form again where you
66- can edit the name and value of your secret:
67-
68- ![ Icons] ( ./images/secrets-5.png )
69-
70- This will take effect automatically and it will also restart your sandbox to
53+ Once saved, this will take effect automatically, restarting your sandbox to
7154make sure we use the new value.
7255
73- To delete you can click on the ` x ` icon after the pencil one and this one will
56+ To delete you can click on the ` x ` icon. This will
7457also restart your sandbox.
0 commit comments