-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
Environment
{
"name": "open-authenticator-backend",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "nitro build",
"dev": "nitro dev",
"preview": "nitro preview"
},
"imports": {
"#*": "./*"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@stylistic/eslint-plugin": "^5.10.0",
"@types/ms": "^2.1.0",
"@types/nodemailer": "^7.0.11",
"@types/semver": "^7.7.1",
"eslint": "^10.0.3",
"globals": "^17.4.0",
"typescript-eslint": "^8.57.1"
},
"dependencies": {
"@puzzmo/revenue-cat-webhook-types": "^1.1.0",
"@sentry/core": "^10.45.0",
"arctic": "^3.7.0",
"dotenv": "^17.3.1",
"jiti": "^2.6.1",
"jose": "^6.2.2",
"ms": "^2.1.3",
"nitro": "latest",
"nodemailer": "^8.0.3",
"semver": "^7.7.4",
"smob": "^1.6.1",
"xss": "^1.0.15"
}
}
node --version
v22.22.0
Reproduction
Configure Nitro to use a Cloudflare D1 database :
database: {
default: {
connector: 'cloudflare-d1',
options: {
bindingName: 'DATABASE',
},
},
},
And try to use useDatabase().
Describe the bug
I'm currently trying to use useDatabase() to do some basic operations on my Cloudflare D1 database (see https://github.com/openauthenticator-app/backend/blob/dev/routes/admin/reset.ts). But I end up with the following error : [db0] [d1] binding DATABASE not found.
Note that my bindings are correctly configured on Cloudflare using wrangler.json :
Extra details
Here's the log I have on my local development server :
> open-authenticator-backend@1.0.0 build
> nitro build
✔ Generated public dist nitro 21:26:53
ℹ Initializing prerenderer nitro 21:26:53
ℹ Generated dist/nitro.json 21:26:53
ℹ Prerendering 1 routes nitro 21:26:53
├─ / (9ms) nitro 21:26:53
ℹ Prerendered 1 routes in 0.405 seconds nitro 21:26:53
ℹ Building server (builder: rolldown, preset: cloudflare-pages, compatibility date: 2026-03-22) nitro 21:26:53
WARN inlineDynamicImports option is ignored because the codeSplitting option is specified.
ℹ Generated dist/nitro.json 21:26:54
✔ Server built in 160ms nitro 21:26:54
├─ dist/_worker.js/_chunks/auth.mjs (22.5 kB) (4.84 kB gzip)
├─ dist/_worker.js/_chunks/headers.mjs (1.8 kB) (658 B gzip)
├─ dist/_worker.js/_chunks/nitro.mjs (1.17 kB) (515 B gzip)
├─ dist/_worker.js/_chunks/package.mjs (136 B) (126 B gzip)
├─ dist/_worker.js/_chunks/ratelimit.mjs (9.28 kB) (2.65 kB gzip)
├─ dist/_worker.js/_chunks/session.mjs (6.1 kB) (1.7 kB gzip)
├─ dist/_worker.js/_chunks/storage.mjs (4.45 kB) (1.8 kB gzip)
├─ dist/_worker.js/_chunks/task.mjs (1.56 kB) (730 B gzip)
├─ dist/_worker.js/_chunks/user.mjs (7.67 kB) (2.12 kB gzip)
├─ dist/_worker.js/_chunks/user2.mjs (586 B) (326 B gzip)
├─ dist/_worker.js/_chunks/utils.mjs (3.04 kB) (1.24 kB gzip)
├─ dist/_worker.js/_chunks/validation.mjs (1.4 kB) (562 B gzip)
├─ dist/_worker.js/_libs/arctic.mjs (19.1 kB) (3.33 kB gzip)
├─ dist/_worker.js/_libs/cssfilter.mjs (19 kB) (3.85 kB gzip)
├─ dist/_worker.js/_libs/db0.mjs (5.17 kB) (1.73 kB gzip)
├─ dist/_worker.js/_libs/h3+rou3+srvx.mjs (26.3 kB) (7.44 kB gzip)
├─ dist/_worker.js/_libs/hookable.mjs (1.13 kB) (507 B gzip)
├─ dist/_worker.js/_libs/jose.mjs (38.8 kB) (8.95 kB gzip)
├─ dist/_worker.js/_libs/ms.mjs (2.99 kB) (1.1 kB gzip)
├─ dist/_worker.js/_libs/nodemailer.mjs (362 kB) (81.6 kB gzip)
├─ dist/_worker.js/_libs/oslojs__binary.mjs (3.89 kB) (684 B gzip)
├─ dist/_worker.js/_libs/oslojs__crypto.mjs (4.02 kB) (1.53 kB gzip)
├─ dist/_worker.js/_libs/oslojs__encoding.mjs (6.77 kB) (1.38 kB gzip)
├─ dist/_worker.js/_libs/oslojs__jwt.mjs (1.5 kB) (516 B gzip)
├─ dist/_worker.js/_libs/semver.mjs (50.5 kB) (10.1 kB gzip)
├─ dist/_worker.js/_libs/sentry__core+unenv.mjs (177 kB) (46.9 kB gzip)
├─ dist/_worker.js/_libs/smob.mjs (6.44 kB) (1.81 kB gzip)
├─ dist/_worker.js/_libs/unstorage.mjs (21.7 kB) (5.39 kB gzip)
├─ dist/_worker.js/_libs/xss.mjs (22.6 kB) (5.64 kB gzip)
├─ dist/_worker.js/_routes/admin/prune.mjs (669 B) (347 B gzip)
├─ dist/_worker.js/_routes/admin/reset.mjs (1.26 kB) (496 B gzip)
├─ dist/_worker.js/_routes/auth/logout.mjs (824 B) (427 B gzip)
├─ dist/_worker.js/_routes/auth/provider/[provider]/callback.mjs (587 B) (309 B gzip)
├─ dist/_worker.js/_routes/auth/provider/[provider]/callback2.mjs (1.09 kB) (498 B gzip)
├─ dist/_worker.js/_routes/auth/provider/[provider]/cancel.mjs (995 B) (495 B gzip)
├─ dist/_worker.js/_routes/auth/provider/[provider]/link.mjs (603 B) (313 B gzip)
├─ dist/_worker.js/_routes/auth/provider/[provider]/login.mjs (690 B) (344 B gzip)
├─ dist/_worker.js/_routes/auth/provider/[provider]/redirect.mjs (587 B) (304 B gzip)
├─ dist/_worker.js/_routes/auth/provider/[provider]/unlink.mjs (611 B) (314 B gzip)
├─ dist/_worker.js/_routes/auth/refresh.mjs (1.04 kB) (490 B gzip)
├─ dist/_worker.js/_routes/index.mjs (303 B) (213 B gzip)
├─ dist/_worker.js/_routes/totps.mjs (569 B) (323 B gzip)
├─ dist/_worker.js/_routes/totps/[uuid].mjs (841 B) (419 B gzip)
├─ dist/_worker.js/_routes/totps/[uuid]2.mjs (897 B) (456 B gzip)
├─ dist/_worker.js/_routes/totps/sync/pull.mjs (1.42 kB) (629 B gzip)
├─ dist/_worker.js/_routes/totps/sync/push.mjs (5.47 kB) (1.49 kB gzip)
├─ dist/_worker.js/_routes/totps2.mjs (582 B) (327 B gzip)
├─ dist/_worker.js/_routes/totps3.mjs (1 kB) (492 B gzip)
├─ dist/_worker.js/_routes/user.mjs (588 B) (328 B gzip)
├─ dist/_worker.js/_routes/user2.mjs (513 B) (297 B gzip)
├─ dist/_worker.js/_routes/webhooks/revenuecat.mjs (4.42 kB) (1.36 kB gzip)
├─ dist/_worker.js/_runtime.mjs (1.65 kB) (796 B gzip)
├─ dist/_worker.js/_tasks/prune.mjs (549 B) (296 B gzip)
└─ dist/_worker.js/index.js (20.1 kB) (5.37 kB gzip)
Σ Total size: 876 kB (217 kB gzip)
WARN [cloudflare] Wrangler config pages_build_output_dir is overridden and will be ignored. nitro 21:26:54
ℹ Generated dist/_worker.js/wrangler.json 21:26:54
ℹ Generated .wrangler/deploy/config.json 21:26:54
ℹ Generated dist/_routes.json 21:26:54
ℹ Generated dist/_headers 21:26:54
ℹ Generated dist/_redirects 21:26:54
✔ You can preview this build using npx nitro preview nitro 21:26:54
✔ You can deploy this build using npx nitro deploy --prebuilt nitro 21:26:54
⛅️ wrangler 4.76.0
───────────────────
Using redirected Wrangler configuration.
- Configuration being used: "dist/_worker.js/wrangler.json"
- Original user's configuration: "wrangler.json"
- Deploy configuration file: ".wrangler/deploy/config.json"
Attaching additional modules:
┌────────────────────────────────────────────────┬──────┬────────────┐
│ Name │ Type │ Size │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _chunks/auth.mjs │ esm │ 21.96 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _chunks/headers.mjs │ esm │ 1.76 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _chunks/nitro.mjs │ esm │ 1.14 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _chunks/package.mjs │ esm │ 0.13 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _chunks/ratelimit.mjs │ esm │ 9.06 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _chunks/session.mjs │ esm │ 5.96 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _chunks/storage.mjs │ esm │ 4.35 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _chunks/task.mjs │ esm │ 1.52 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _chunks/user.mjs │ esm │ 7.49 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _chunks/user2.mjs │ esm │ 0.57 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _chunks/utils.mjs │ esm │ 2.97 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _chunks/validation.mjs │ esm │ 1.36 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/arctic.mjs │ esm │ 18.64 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/cssfilter.mjs │ esm │ 18.52 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/db0.mjs │ esm │ 5.05 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/h3+rou3+srvx.mjs │ esm │ 25.69 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/hookable.mjs │ esm │ 1.10 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/jose.mjs │ esm │ 37.88 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/ms.mjs │ esm │ 2.92 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/nodemailer.mjs │ esm │ 353.63 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/oslojs__binary.mjs │ esm │ 3.80 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/oslojs__crypto.mjs │ esm │ 3.93 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/oslojs__encoding.mjs │ esm │ 6.61 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/oslojs__jwt.mjs │ esm │ 1.46 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/semver.mjs │ esm │ 49.28 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/sentry__core+unenv.mjs │ esm │ 172.38 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/smob.mjs │ esm │ 6.29 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/unstorage.mjs │ esm │ 21.24 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _libs/xss.mjs │ esm │ 22.04 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/admin/prune.mjs │ esm │ 0.65 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/admin/reset.mjs │ esm │ 1.23 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/auth/logout.mjs │ esm │ 0.80 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/auth/provider/[provider]/callback.mjs │ esm │ 0.57 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/auth/provider/[provider]/callback2.mjs │ esm │ 1.07 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/auth/provider/[provider]/cancel.mjs │ esm │ 0.97 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/auth/provider/[provider]/link.mjs │ esm │ 0.59 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/auth/provider/[provider]/login.mjs │ esm │ 0.67 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/auth/provider/[provider]/redirect.mjs │ esm │ 0.57 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/auth/provider/[provider]/unlink.mjs │ esm │ 0.60 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/auth/refresh.mjs │ esm │ 1.02 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/index.mjs │ esm │ 0.30 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/totps/[uuid].mjs │ esm │ 0.82 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/totps/[uuid]2.mjs │ esm │ 0.88 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/totps/sync/pull.mjs │ esm │ 1.38 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/totps/sync/push.mjs │ esm │ 5.35 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/totps.mjs │ esm │ 0.56 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/totps2.mjs │ esm │ 0.57 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/totps3.mjs │ esm │ 0.98 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/user.mjs │ esm │ 0.57 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/user2.mjs │ esm │ 0.50 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _routes/webhooks/revenuecat.mjs │ esm │ 4.31 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _runtime.mjs │ esm │ 1.61 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ _tasks/prune.mjs │ esm │ 0.54 KiB │
├────────────────────────────────────────────────┼──────┼────────────┤
│ Total (53 modules) │ │ 835.84 KiB │
└────────────────────────────────────────────────┴──────┴────────────┘
✨ Compiled Worker successfully
✨ Parsed 0 valid redirect rules.
✨ Parsed 0 valid header rules.
Using redirected Wrangler configuration.
- Configuration being used: "dist/_worker.js/wrangler.json"
- Original user's configuration: "wrangler.json"
- Deploy configuration file: ".wrangler/deploy/config.json"
Using secrets defined in .env
Your Worker has access to the following bindings:
Binding Resource Mode
env.STORAGE (HIDDEN) KV Namespace local
env.DATABASE (HIDDEN) D1 Database local
env.BUCKET (HIDDEN) R2 Bucket local
env.CF_VERSION_METADATA Worker Version Metadata local
env.CF_PAGES ("1") Environment Variable local
env.CF_PAGES_BRANCH ("dev") Environment Variable local
env.CF_PAGES_COMMIT_SHA ("dfc1ff2a58eb315c6132a4ff4b867713e213c...") Environment Variable local
env.CF_PAGES_URL ("https://dfc1ff2.openauthenticator-bac...") Environment Variable local
env.NODE_ENV ("(hidden)") Environment Variable local
env.URL ("(hidden)") Environment Variable local
env.GOOGLE_CLIENT_ID ("(hidden)") Environment Variable local
env.GITHUB_CLIENT_ID ("(hidden)") Environment Variable local
env.MICROSOFT_CLIENT_ID ("(hidden)") Environment Variable local
env.MICROSOFT_TENANT_ID ("(hidden)") Environment Variable local
env.APPLE_CLIENT_ID ("(hidden)") Environment Variable local
env.APPLE_KEY_ID ("(hidden)") Environment Variable local
env.APPLE_TEAM_ID ("(hidden)") Environment Variable local
env.SENTRY_DSN ("(hidden)") Environment Variable local
env.EMAIL_HOST ("(hidden)") Environment Variable local
env.EMAIL_USERNAME ("(hidden)") Environment Variable local
env.REVENUE_CAT_AUTHORIZATION_HEADER ("(hidden)") Environment Variable local
env.JWT_ACCESS_SECRET ("(hidden)") Environment Variable local
env.JWT_REFRESH_SECRET ("(hidden)") Environment Variable local
env.JWT_REFRESH_PEPPER ("(hidden)") Environment Variable local
env.GOOGLE_CLIENT_SECRET ("(hidden)") Environment Variable local
env.APPLE_PEM_CERTIFICATE ("(hidden)") Environment Variable local
env.GITHUB_CLIENT_SECRET ("(hidden)") Environment Variable local
env.MICROSOFT_CLIENT_SECRET ("(hidden)") Environment Variable local
env.EMAIL_PASSWORD ("(hidden)") Environment Variable local
╭──────────────────────────────────────────────────────────────────────╮
│ [b] open a browser [d] open devtools [c] clear console [x] to exit │
╰──────────────────────────────────────────────────────────────────────╯
⎔ Starting local server...
[wrangler:info] Ready on http://localhost:8788
✘ [ERROR] Error: [db0] [d1] binding `DATABASE` not found
at getDB
(file:///var/mnt/data/Projets/WebStorm/OpenAuthenticatorCloudflareBackend/.wrangler/tmp/pages-0ohCHB/_libs/db0.mjs:139:23)
... 5 lines matching cause stack trace ...
at async drainBody
(file:///home/hugo/.npm/_npx/32026684e21afda6/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts:5:10)
{
cause: Error: [db0] [d1] binding `DATABASE` not found
at getDB
(file:///var/mnt/data/Projets/WebStorm/OpenAuthenticatorCloudflareBackend/.wrangler/tmp/pages-0ohCHB/_libs/db0.mjs:139:23)
at Object.prepare
(file:///var/mnt/data/Projets/WebStorm/OpenAuthenticatorCloudflareBackend/.wrangler/tmp/pages-0ohCHB/_libs/db0.mjs:147:42)
at Object.prepare
(file:///var/mnt/data/Projets/WebStorm/OpenAuthenticatorCloudflareBackend/.wrangler/tmp/pages-0ohCHB/_libs/db0.mjs:58:21)
at null.<anonymous>
(file:///var/mnt/data/Projets/WebStorm/OpenAuthenticatorCloudflareBackend/.wrangler/tmp/pages-0ohCHB/_routes/admin/reset.mjs:6:11)
at null.<anonymous>
(file:///var/mnt/data/Projets/WebStorm/OpenAuthenticatorCloudflareBackend/.wrangler/tmp/pages-0ohCHB/_libs/h3+rou3+srvx.mjs:512:19)
at async jsonError
(file:///home/hugo/.npm/_npx/32026684e21afda6/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:10)
at async drainBody
(file:///home/hugo/.npm/_npx/32026684e21afda6/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts:5:10),
status: 500,
statusText: undefined,
headers: undefined,
data: undefined,
body: undefined,
unhandled: true
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels