It did not work with the variable. The expression must always be fixed at runtime. Nevertheless, I was able to solve the problem because the path can also be specified relatively:
const str3 = “/sse”;
var source = new EventSource(str3);
This works perfectly!