Skip to content

Remove Cloudflare Pages Functions from website stack #282

@markoa

Description

@markoa

Context

PR #281 restored the homepage by adding a temporary root Pages Function fallback. That fixed the production outage, but it means homepage requests invoke the Pages Functions runtime. We should remove Pages Functions from the website stack and make the Astro site pure static again.

Production also had Cloudflare Web Analytics injection enabled. The homepage stayed 500 after the merge until Web Analytics was disabled and the production deployment was retried. That setting should remain off unless we can prove it no longer breaks homepage HTML serving.

Target state

  • operately.com is served as static Astro assets only.
  • No functions/ directory in this repository.
  • No _routes.json needed for Pages Functions routing.
  • Contact form submits to an API endpoint outside the Pages static site.
  • Homepage and contact form behavior are verified on both preview and production URLs before removing the fallback.

Proposed plan

  1. Move contact handling out of Cloudflare Pages Functions.

    • Preferred: create a separate Worker, e.g. contact.operately.com or api.operately.com/contact.
    • Alternative: send contact form submissions to an existing backend endpoint if one is already appropriate.
    • Keep SendGrid secrets in the destination service, not in the website Pages project.
  2. Update the website contact form.

    • Replace /api/contact with the new absolute API URL.
    • Confirm CORS, method handling, JSON validation, and error responses.
    • Add/update a focused test or manual verification script for successful and malformed submissions.
  3. Remove Pages Functions from this repo.

    • Delete functions/api/contact.ts.
    • Delete temporary functions/index.ts.
    • Delete public/_routes.json.
    • Keep src/pages/home.astro only if still needed for investigation; otherwise collapse HomePage.astro back into normal homepage structure or leave it as a harmless component extraction.
  4. Validate Cloudflare Pages as pure static.

    • Deploy a preview with no functions/ directory.
    • Verify:
      • curl -I https://<preview>.operately-website.pages.dev/ returns 200.
      • curl -I https://<preview>.operately-website.pages.dev/contact/ returns 200.
      • Contact form posts successfully to the new external API.
    • Merge and verify production https://operately.com/ returns 200.
  5. Keep Cloudflare Web Analytics disabled for now.

    • If analytics are needed, reintroduce via explicit app-side analytics code or test Cloudflare Web Analytics in a preview/staging project first.
    • Do not re-enable Pages Web Analytics on production until homepage static serving is verified after a fresh production deploy.

Exit criteria

  • The website Pages project reports uses_functions: false on the latest production deployment.
  • https://operately.com/ returns 200 without a root Pages Function.
  • Contact submissions still work through the replacement endpoint.
  • Cloudflare Pages Web Analytics remains disabled or has a documented, tested replacement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions