The Angular Server Sent Event this.eventSource.onmessage
call fails with an error "EventSource's response has a MIME type ("application/json") that is not "text/event-stream". Aborting the connection."
I see in the Chrome Dev Tools (image attached) that there are two Content-Type
being returned.
Backend Code:Spring Reactor/REST
@GetMapping(value="/events",produces = "text/event-stream;charset=UTF-8")
public Flux<ConsumerEvent> getProductEvents(){
return kafkaService.getReceiverRecordAllFlux()
.map(record->
new ConsumerEvent(record.topic(),record.value())
);
}
}
Front end:Angular
public startKafkaTopicInfoEventSource(): void {
let url = BASE_URL;
this.eventSource = new EventSource(url);
this.eventSource.onmessage = (event) => {//Error: EventSource's response has a MIME type ("application/json") that is not "text/event-stream". Aborting the connection
this.zone.run(() => {
// some code here
})
}
// other code here
}
The method this.eventSource.onmessage
gives an error EventSource's response has a MIME type ("application/json") that is not "text/event-stream". Aborting the connection.
Any help would be great!