diff --git a/m365-developer-proxy/ProxyEngine.cs b/m365-developer-proxy/ProxyEngine.cs index fda3b068..ca7e9b75 100644 --- a/m365-developer-proxy/ProxyEngine.cs +++ b/m365-developer-proxy/ProxyEngine.cs @@ -384,8 +384,9 @@ private async Task HandleRequest(SessionEventArgs e) { // Modify response async Task OnBeforeResponse(object sender, SessionEventArgs e) { + var method = e.HttpClient.Request.Method.ToUpper(); // read response headers - if (IsProxiedHost(e.HttpClient.Request.RequestUri.Host)) { + if (method is not "OPTIONS" && IsProxiedHost(e.HttpClient.Request.RequestUri.Host)) { // necessary to make the response body available to plugins e.HttpClient.Response.KeepBody = true; await e.GetResponseBody(); @@ -394,8 +395,9 @@ async Task OnBeforeResponse(object sender, SessionEventArgs e) { } } async Task OnAfterResponse(object sender, SessionEventArgs e) { + var method = e.HttpClient.Request.Method.ToUpper(); // read response headers - if (IsProxiedHost(e.HttpClient.Request.RequestUri.Host)) { + if (method is not "OPTIONS" && IsProxiedHost(e.HttpClient.Request.RequestUri.Host)) { _logger.LogRequest(new[] { $"{e.HttpClient.Request.Method} {e.HttpClient.Request.Url}" }, MessageType.InterceptedResponse, new LoggingContext(e)); _pluginEvents.RaiseProxyAfterResponse(new ProxyResponseArgs(e, _throttledRequests, new ResponseState())); }