]> git.ardis.lu - ardislu.dev/commitdiff
Update README to use wrangler for development
authorArdis Lu <ardisglu@gmail.com>
Fri, 25 Mar 2022 07:13:08 +0000 (00:13 -0700)
committerArdis Lu <ardisglu@gmail.com>
Fri, 25 Mar 2022 07:13:08 +0000 (00:13 -0700)
README.md

index fe3257f2dc9860b6b7473600ed26d8a37e42fce5..1dab0fbfc904584e0c976b354a175f40f79a1be9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -12,16 +12,12 @@ I'm using Google Sheets and Google Docs as the CMS for this website. A Google Sh
 
 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"`
This page took 0.045837 seconds and 4 git commands to generate.