Server Sent Events, with SSL off loading. - Our server is SSL up to the AWS load balancer and is plain HTTP to IIS. cmd.Connect is sending back full paths of what it sees - plain http and not https. This is rejected. How can I override this behaviour? Can’t it just send relative paths?
You can intercept and customize the urls sent back by registering a a custom handler in ServerEventsFeature.OnConnect
and modifying the 2nd args Dictionary.
Aaron Langley:
yes that solves it Is it possible to throw HttpError.Unauthorized or return 401 in any of these OnConnect or OnCreated events? Currently is being captured as a 500 error.
No. but if LimitToAuthenticatedUsers=true
and !session.IsAuthenticated
then it automatically returns a 401.
Aaron Langley:
Nice, thanks
__________
Also if you want to rewrite http links to https in all links there’s a Config.UseHttpsLinks=true
option you can use instead.
Aaron Langley:
Yes that’s probably less over head than what I’m doing here
OnConnect = (IEventSubscription sub, Dictionary<string, string> map) => {
var urlKeys = map.Where(X => X.Key.EndsWith(“Url”)).Select(X => X.Key).ToArray();
foreach (var url in urlKeys) {
map[url] = new Uri(map[url]).PathAndQuery;
}
}