middleware
middleware copied to clipboard
how to access env outside fetch, when working with oauth-handlers
githubAuth({
client_id: Bun.env.GITHUB_ID,
client_secret: Bun.env.GITHUB_SECRET,
I see, @yusukebe you have used Bun.env
, but without using Bun
how can i get the env from .env files.
Hi @KunalSin9h
You may use the env()
function in hono/adapter
.
https://hono.dev/helpers/adapter#env
If you're using node.js.
import process from 'node:process'
...
githubAuth({
client_id: process.env.GITHUB_ID,
client_secret: process.env.GITHUB_SECRET,
Or you can write the following:
app.use('*', async (c, next) => {
await githubAuth({
client_id: env(c),
client_secret: env(c),
//..
})(c, next)
})