listmonk
listmonk copied to clipboard
Add optional CORS header middleware
Optional CORS header middleware with configs like:
[cors] enabled = true allowed_origins = ["example.com"]
or with environment variable like (in docker compose for example):
app:
<<: *app-defaults
container_name: listmonk_app
command: [ sh, -c, "yes | ./listmonk --config config.toml" ]
depends_on:
- db
volumes:
- ./config.toml:/listmonk/config.toml
environment:
- LISTMONK_cors__enabled=true
- LISTMONK_cors__allowed_origins__0=*
- LISTMONK_cors__allowed_origins__1=http://localhost:3000
- LISTMONK_cors__allowed_origins__2=google.com
- LISTMONK_cors__allowed_origins__2=another.com
Note: the google.com is overriden with another.com in this example.
With enabled false, everything works as before, so it doesn't break backward the compatibility. Without array of origins, it shows a warning, but works like cors disabled.
Inspiration for this PR: https://github.com/knadh/listmonk/issues/1521