Closed yusukebe closed 1 year ago
Hey @Code-Hex !
Could you review this?
Latest commit: 1e7f4ae27c3a323f5fd97d1b6947ae269cba1ac2
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
@Code-Hex
Thanks for reviewing. Let's go with this!
This PR introduces the concept of
ENV
and theenv
option.For Cloudflare Pages, the current
cf
option allows us to use bindings. For example:With this configuration, we can access variables through
c.env
:This is currently exclusive to Cloudflare Pages, but in the future, it may be extended to other runtimes/platforms with specific environment values. While
c.env
seems to be used for Cloudflare, other platforms/runtimes may also use bindings/c.env
. For instance, the AWS Lambda adapter currently usesenv
:https://github.com/honojs/hono/blob/main/src/adapter/aws-lambda/handler.ts#L126-L143
This PR suggests separating the Cloudflare Pages-specific functionality from
dev-server.ts
. With this change, thegetEnv()
method for Cloudflare Pages is placed incloudflare-pages/index.ts
, and users can include theenv
in theirvite.config.ts
:With this mechanism, adding support for another platform that uses environment variables becomes straightforward: