caddy as a cors proxy #
To protect your API with CORS, our caddy ships with a CORS config. To enable it, see the snippet below.
The example scenario is as follows: Caddy proxies a container running your API on api.example.org
, but you need the frontend on https://example.org/
to access it.
deploy:
labels:
caddy: api.example.org
caddy.import: cors-origin http://example.org
To add multiple domains:
deploy:
labels:
caddy: api.example.org
caddy.import_0: cors-origin http://example.org
caddy.import_1: cors-origin http://another.example.org