Configuration and docs for deploying the proxy to Cloudflare

This commit is contained in:
Matt Aitken
2023-11-14 14:04:42 +00:00
parent 75550f535c
commit f406e59c45
4 changed files with 36 additions and 10 deletions
+24 -8
View File
@@ -12,7 +12,7 @@ The Trigger.dev API is designed to be fast and reliable. However, if you have a
## Setup
### 1. Create an AWS SQS queue
### Create an AWS SQS queue
In AWS you should create a new AWS SQS queue with appropriate security settings. You will need the queue URL for the next step.
@@ -22,19 +22,21 @@ In AWS you should create a new AWS SQS queue with appropriate security settings.
Locally you should copy the `.dev.var.example` file to `.dev.var` and fill in the values.
When deploying you should use `wrangler` (the Cloudflare CLI tool) to set secrets.
When deploying you should use `wrangler` (the Cloudflare CLI tool) to set secrets. Make sure you set the correct --env ("staging" or "prod")
```bash
wrangler secret put REWRITE_HOSTNAME
wrangler secret put AWS_SQS_ACCESS_KEY_ID
wrangler secret put AWS_SQS_SECRET_ACCESS_KEY
wrangler secret put AWS_SQS_QUEUE_URL
wrangler secret put AWS_SQS_REGION
wrangler secret put REWRITE_HOSTNAME --env staging
wrangler secret put AWS_SQS_ACCESS_KEY_ID --env staging
wrangler secret put AWS_SQS_SECRET_ACCESS_KEY --env staging
wrangler secret put AWS_SQS_QUEUE_URL --env staging
wrangler secret put AWS_SQS_REGION --env staging
```
You need to set your API CNAME entry to be proxied by Cloudflare. You can do this in the Cloudflare dashboard.
#### Webapp
These env vars also need setting in the webapp, however you normally would do that.
These env vars also need setting in the webapp.
```bash
AWS_SQS_REGION
@@ -44,6 +46,20 @@ AWS_SQS_QUEUE_URL
AWS_SQS_BATCH_SIZE
```
## Deployment
Staging:
```bash
npx wrangler@latest deploy --route "<your-api-subdomain>/*" --env staging
```
Prod:
```bash
npx wrangler@latest deploy --route "<your-api-subdomain>/*" --env prod
```
## Development
Set the environment variables as described above.
+6 -1
View File
@@ -58,5 +58,10 @@ function redirectToOrigin(request: Request, env: Env) {
}
function queueingIsEnabled(env: Env) {
return env.AWS_SQS_ACCESS_KEY_ID && env.AWS_SQS_SECRET_ACCESS_KEY && env.AWS_SQS_QUEUE_URL;
return (
env.AWS_SQS_ACCESS_KEY_ID &&
env.AWS_SQS_SECRET_ACCESS_KEY &&
env.AWS_SQS_QUEUE_URL &&
env.AWS_SQS_REGION
);
}
+1
View File
@@ -26,6 +26,7 @@
"strict": true /* Enable all strict type-checking options. */,
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
"baseUrl": ".",
"paths": {
"@trigger.dev/core": ["../../packages/core/src/index"],
"@trigger.dev/core/*": ["../../packages/core/src/*"]
+5 -1
View File
@@ -1,3 +1,7 @@
name = "proxy"
main = "src/index.ts"
compatibility_date = "2023-10-30"
compatibility_date = "2023-10-30"
compatibility_flags = [ "nodejs_compat" ]
[env.staging]
[env.prod]