I have found the solution.
I put this in my config.json
"cors": {
"enabled": true,
"allow_origin": ["http://localhost:4200"],
"allow_headers": ["Content-Type", "Authorization"],
"allow_methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
}
and this in my caddy configuration file
my.url.com {
reverse_proxy 192.168.1.2:14002
@localhost_origin {
header Origin "http://localhost:4200"
}
header @localhost_origin Access-Control-Allow-Origin "http://localhost:4200"
header {
Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
Access-Control-Allow-Headers "Content-Type, Authorization"
Access-Control-Allow-Credentials true
}
# Handle OPTIONS requests explicitly
@options_method {
method OPTIONS
}
respond @options_method 200
}