Skip to content

Deployment and subdomains

Deploy your app wherever suits you, then request a hasanat.dev subdomain if you want one. A maintainer connects it in the way that fits your host.

The starter uses Astro 5 with Cloudflare Pages: wrangler.toml contains pages_build_output_dir = "./dist". You need a Cloudflare account, then:

نافذة طرفيّة
npx wrangler login
npm run build
npx wrangler pages deploy dist/
  • Set the project name in wrangler.toml, plus PUBLIC_SITE_URL and PUBLIC_APP_NAME under [vars].
  • Shared sign-in needs no secrets. If your app needs a secret of its own, set it with npx wrangler pages secret put NAME, never in the repository.
  • The starter’s public/_headers file adds basic security headers to every page.
  • Deploy only after npm run check and npm run build pass.

You can deploy on every merge to the main branch with GitHub Actions:

.github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- run: npm run build
- uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: pages deploy dist/ --project-name=your-app-name

Store CLOUDFLARE_API_TOKEN as a secret in the repository’s GitHub settings, never in the code.

Request a “subdomain” from the platform dashboard once your app works. Include:

  • The name you want: lowercase letters, digits, and hyphens, one level only, such as your-app.hasanat.dev. Shared sign-in does not accept two-level names such as app.your-app.hasanat.dev.
  • Where the app runs: a Cloudflare Pages project or Worker, and in which account, or another host.
  • Its current URL: for example your-app.pages.dev.
  • You: nothing.
  • The maintainer: adds the name as a Custom Domain on the Worker; Cloudflare creates the DNS record and certificate.
  • You: nothing.
  • The maintainer: adds the domain in the project’s settings; Cloudflare creates the DNS record.
  • You: add the domain first: Workers & Pages → your project → Custom domains → Set up a domain.
  • The maintainer: adds a CNAME record pointing to your-app.pages.dev.
  • You: add the domain in the host’s settings, and copy the records it asks for into the request.
  • The maintainer: adds the DNS records the host asked for.

It cannot be connected directly: Cloudflare requires the Worker to be in the account that owns the hasanat.dev zone. Agree in the request on deploying to Pages or to the Hasanat account.

After it is connected, open https://name.hasanat.dev and check that the page loads with a valid certificate. If your app uses shared sign-in, try it now: it does not work on localhost, *.pages.dev, or *.workers.dev.

You don’t have to use Cloudflare. Deploy your app anywhere and request a subdomain that points to it. Shared sign-in works when the app is served on its hasanat.dev subdomain and its server asks the auth service for the session, as described in sign-in.