From 66b97551ba3ac51d147e247f0dcdeebeac0af8f1 Mon Sep 17 00:00:00 2001 From: Ben Guild Date: Thu, 15 Jun 2023 00:06:26 -0600 Subject: [PATCH 1/2] Suggesting using Secrets instead --- README.md | 4 ++-- wrangler.toml | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8e1b8c4..fd2e2f4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ 1. Clone this repository 2. Install the dependencies with `npm install` -3. Add a random `TOKEN` to the `wrangler.toml` file (this will be used to authenticate your requests) +3. Deploy a secure token using `npx wrangler secret put --env production TOKEN` (this will be used to authenticate your requests, and is encrypted on Cloudflare) 4. Deploy the worker with `npm run deploy` Or deploy directly to cloudflare @@ -33,7 +33,7 @@ This step is optional, but highly recommended. DKIM is a DNS record that helps p Once you have deployed this worker function to Cloudflare Workers, you can send emails by making a `POST` request to the worker on the `/api/email` endpoint with the following parameters: -- Note you need to pass an `Authorization` header with the `TOKEN` you set in the `wrangler.toml` file. Like the following: `Authorization: TOKEN` +- Note you need to pass an `Authorization` header with the secure token you deployed. Like the following: `Authorization: TOKEN` ### Basic Email diff --git a/wrangler.toml b/wrangler.toml index bab287e..540a9f4 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -1,7 +1,3 @@ name = "worker-email" main = "src/main.ts" compatibility_date = "2023-05-18" - -#[env.production] -#[env.production.vars] -#TOKEN = "production_value" From 26aa4bcc2f0514f06221fcefe2a1c24cd854d5ca Mon Sep 17 00:00:00 2001 From: Ben Guild Date: Thu, 15 Jun 2023 01:12:12 -0600 Subject: [PATCH 2/2] revs, RE: https://github.com/Sh4yy/cloudflare-email/pull/2#issuecomment-1592480397 --- README.md | 2 +- wrangler.toml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fd2e2f4..10573d3 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ 1. Clone this repository 2. Install the dependencies with `npm install` -3. Deploy a secure token using `npx wrangler secret put --env production TOKEN` (this will be used to authenticate your requests, and is encrypted on Cloudflare) +3. Use the command `npx wrangler secret put --env production TOKEN` to deploy a securely stored token to Cloudflare. With this command, you will be prompted to enter a random secret value, which will be used to authenticate your requests with the HTTP `Authorization` header as described below. You can also set this encrypted value directly in your Cloudflare dashboard. 4. Deploy the worker with `npm run deploy` Or deploy directly to cloudflare diff --git a/wrangler.toml b/wrangler.toml index 540a9f4..4b84cd4 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -1,3 +1,6 @@ name = "worker-email" main = "src/main.ts" compatibility_date = "2023-05-18" + +[env.production] +