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

Unified access to environment variables? #140

Open
KGZM opened this issue Feb 6, 2024 · 3 comments
Open

Unified access to environment variables? #140

KGZM opened this issue Feb 6, 2024 · 3 comments

Comments

@KGZM
Copy link

KGZM commented Feb 6, 2024

If c.env is intended to be for uniform environment access then we need some way to provide values to c.env when using the node-server.

I read issue #72, but the discussion there seems to miss the point. The problem isn't reading the environment, it's providing it.

Take a look at this search for c.env on the middleware repo.

The decision tree "If on cloudflare workers use c.env, else if on NodeJS use process.env" doesn't seem to work with shared middleware.

How is shared middleware supposed to work if c.env and process.env remain entirely separate?

@yusukebe
Copy link
Member

yusukebe commented Feb 8, 2024

Hi @KGZM

We should use env() in hono/adapter.

import { env } from 'hono/adapter'

That, the code in the search results is not good. Many of these were created when there was no hono/adapter yet, and also assumed Cloudflare Workers. We should have used env().

@thecotne
Copy link

@yusukebe should c.env be deprecated and all first party packages migrated to use hono/adapter ?

@yusukebe
Copy link
Member

yusukebe commented Jun 3, 2024

@thecotne

@yusukebe should c.env be deprecated and all first party packages migrated to use hono/adapter ?

No. We have to recommend using c.env for the Cloudflare Workers/Pages. It is now very familiar to the user. We don't need to stop using it.

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