This is an optional module that can be used to proxy and queue requests to the Trigger.dev API.
The Trigger.dev API is designed to be fast and reliable. However, if you have a lot of traffic, you may want to use this proxy to queue requests to the API. It intercepts some requests to the API and adds them to an AWS SQS queue, then the webapp can be setup to process the queue.
- Intercepts
sendEventrequests and adds them to an AWS SQS queue. The webapp then reads from the queue and creates the events.
In AWS you should create a new AWS SQS queue with appropriate security settings. You will need the queue URL for the next step.
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. Make sure you set the correct --env ("staging" or "prod")
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 stagingYou need to set your API CNAME entry to be proxied by Cloudflare. You can do this in the Cloudflare dashboard.
These env vars also need setting in the webapp.
AWS_SQS_REGION
AWS_SQS_ACCESS_KEY_ID
AWS_SQS_SECRET_ACCESS_KEY
AWS_SQS_QUEUE_URL
AWS_SQS_BATCH_SIZEStaging:
npx wrangler@latest deploy --route "<your-api-subdomain>/*" --env stagingProd:
npx wrangler@latest deploy --route "<your-api-subdomain>/*" --env prodSet the environment variables as described above.
pnpm installpnpm run dev --filter proxy