---
title: "Comment by Andrew Ross on \"Keeping secrets safe with Next.js API routes\" | Hashnode"
description: "Great article! For that client/server dependent secret you could use a ternary to further refine it. const isServer = typeof window === “undefined” fetch( ${isS"
url: "https://hashnode.com/posts/keeping-secrets-safe-with-nextjs-api-routes/5f8157675841661b519d0260/comment/601f6ed2636acc2a3822f048"
---

[Discussion](https://hashnode.com/posts/keeping-secrets-safe-with-nextjs-api-routes/5f8157675841661b519d0260)

Comment [Keeping secrets safe with Next.js API routes](https://hashnode.com/posts/keeping-secrets-safe-with-nextjs-api-routes/5f8157675841661b519d0260)

[Andrew Ross](https://hashnode.com/@AndrewRoss)

[Feb 7, 2021](https://hashnode.com/posts/keeping-secrets-safe-with-nextjs-api-routes/5f8157675841661b519d0260/comment/601f6ed2636acc2a3822f048)

Great article! For that client/server dependent secret you could use a ternary to further refine it.

const isServer = typeof window === “undefined”

fetch(`${isServer ? process.env.BASE_URL : “ “}/api/hello`).then...
