Hello, i am trying to use the rest api in a angular application however I’m getting a cors error.
(Im running it in docker)
I’ve tried adding the following to my config.yaml:
# Loads default set of integrations. Do not remove.
default_config:
# Text to speech
tts:
- platform: google_translate
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
http:
cors_allowed_origins:
- https://192.168.31.266
- http://localhost:4200
- http://192.168.31.266
- https://localhost
- http://localhost
- '*'
It keeps giving me this error:
![]()
This is the request I’m trying to make:
private apiUrl = 'http://localhost:8123/api/services/light/turn_off';
public headers = new HttpHeaders({
'Content-Type': 'application/json',
Autherization: `Bearer (token)`,
});
public turnOff() {
return this.http
.post(
`${this.apiUrl}`,
{
entity_id: 'light.candle_rgb_cct',
},
{ headers: this.headers }
)
.subscribe((res) => {
console.log(res);
});
}