Once I fetch an article from the Google Docs API, the article is converted into markdown then converted into HTML using [marked](https://marked.js.org).
-## Serving actual 404 errors for invalid routes while still being a SPA
+## Local development
-Cloudflare Pages automatically redirects any invalid routes in a directory to `404.html` if there is a `404.html` that exists in that directory. Since there's no `404.html` in the root, Cloudflare Pages will redirect all routes to `index.html`.
+Use the `wrangler` CLI to serve the static frontend and API at the same time. Provide credentials for a service account with access to the Google Docs as environment variables.
-I do a client-side redirect to `/errors/NotFound` for any routes that should have actually been a `404`, which Cloudflare Pages then serves a `404` with `/errors/404.html`.
+From the [Cloudflare Pages documentation](https://developers.cloudflare.com/pages/platform/functions/#develop-and-preview-locally):
-Here's how to replicate this behavior locally:
+1. `npm i wrangler@beta`
-1. Install Node.js (this is ONLY used for the web server; the website itself does not use Node.js)
-
-2. `npm i -g local-web-server`
-
-3. `ws --spa index.html --rewrite '/errors/(.*) -> /errors/404.html'`
+2. `npx wrangler pages dev . --binding EMAIL=\"example@example.com" PRIVATE_KEY=\"-----BEGIN PRIVATE KEY-----\n...EXAMPLE...\n-----END PRIVATE KEY-----\n" SCOPES=\"https://example.com/auth/scope1 https://example.com/auth/scope2"`