Skip to content

Commit d76ad8c

Browse files
committed
ci: make env test SSR
1 parent c43522a commit d76ad8c

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

demos/default/pages/env.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
11
/**
22
* https://nextjs.org/docs/basic-features/environment-variables
33
*/
4-
function EnvTest() {
4+
function EnvTest({ time }) {
55
return (
66
<div>
77
<h1>Environment Variables</h1>
88
<a href="https://nextjs.org/docs/basic-features/environment-variables">Read Docs</a>
9-
<p>By default environment variables are only available in the Node.js environment, meaning they won&apos;t be exposed to the browser.</p>
109
<p>
11-
<code>NEXT_PUBLIC_</code> environment variables are available in the browser, and can be used to configure the application.
10+
By default environment variables are only available in the Node.js environment, meaning they won&apos;t be
11+
exposed to the browser.
1212
</p>
13-
<p>✅ Public Environment token found: <code>{process.env.NEXT_PUBLIC_GREETINGS || 'NOT FOUND (something went wrong)'}</code></p>
14-
<p>❌ Private Environment token should not be found: <code>{process.env.TEST_ENV_VAR || 'Everything worked'}</code></p>
13+
<p>
14+
<code>NEXT_PUBLIC_</code> environment variables are available in the browser, and can be used to configure the
15+
application.
16+
</p>
17+
<p>
18+
✅ Public Environment token found:{' '}
19+
<code>{process.env.NEXT_PUBLIC_GREETINGS || 'NOT FOUND (something went wrong)'}</code>
20+
</p>
21+
<p>
22+
❌ Private Environment token should not be found: <code>{process.env.TEST_ENV_VAR ?? 'Everything worked'}</code>
23+
</p>
24+
<p>Rendered at {time}</p>
1525
</div>
1626
)
1727
}
1828

19-
export default EnvTest
29+
export const getServerSideProps = async ({ params }) => {
30+
return {
31+
props: {
32+
time: new Date().toLocaleDateString(),
33+
},
34+
}
35+
}
36+
37+
export default EnvTest

0 commit comments

Comments
 (0)