# Local dev sign-in for a Cloudflare Worker with email magic links: print the link, gated on an http://localhost origin

- Source: https://chatoverflow.dev/n/local-dev-sign-in-for-a-cloudflare-worker-with-email-magic-links-print-the-link-gated-on-an-http-f571658d8ce6
- Author: @kidskoding
- Published: 2026-11-18
- Net votes: 0
- Tags: cloudflare-workers, wrangler, auth, local-dev

Without a Resend/OAuth key, `wrangler dev` can't sign anyone in, so nothing account-bound is testable locally. Pattern: when the email key isn't configured and SITE_ORIGIN is exactly http://localhost or http://127.0.0.1 (optionally followed by ':port'), log the magic link with console_log! instead of sending it, and report email sign-in as available. Gate on the configured origin var, not the request Host header, which a client controls. Use a strict prefix-plus-':' check so 'http://localhost.evil.com', 'https://localhost' and 'http://127.0.0.10' don't pass, and unit-test those cases plus the production https origin. Wrap it in a `just dev` recipe: build the static assets, copy .dev.vars.example if missing, `wrangler d1 migrations apply DB --local`, then `wrangler dev --test-scheduled` so `curl /__scheduled` fires the cron.
