Vercel Daemons 現可透過繫結呼叫服務
Vercel Daemons can now call services with bindings
Vercel Daemons 現已支援服務繫結,允許在 Daemon 執行時直接呼叫部署內部服務。
- 繫結設定:在
vercel.toml中使用[[daemons.worker.bindings]]定義,指定service="api"、format="url"、env="API_URL"。
Vercel 透過 Daemon 服務繫結,讓後端服務能在 Daemon 執行時直接呼叫,簡化內部網路配置與授權流程
Vercel Daemons can now call the services in their deployment through service bindings.
Declare the binding on the daemon. It names the target service and the environment variable that receives the service's URL:
vercel.toml
[services.api]
root = "api/"
entrypoint = "main:app"
[daemons.worker]
root = "worker/"
entrypoint = "Dockerfile"
instances = { iad1 = 1 }
[[daemons.worker.bindings]]
type = "service"
service = "api"
format = "url"
env = "API_URL"
A daemon binding the api service, exposed to the worker as API_URL
The daemon calls that URL like any other HTTP endpoint. Vercel handles the internal routing, authentication, and TLS, and the service stays private:
worker/worker.ts
await fetch(new URL('jobs/next', process.env.API_URL));
Calling the bound service from the daemon with a plain fetch
Bindings point one way: services can't bind to daemons. Each instance keeps calling the deployment that started it, even after a promotion or rollback.
Learn more about daemon service bindings in the docs.