Skip to content

Commit 21da697

Browse files
Extends the RetryAfterPlugin to support CORS. Closes #526 (#536)
1 parent cfd727d commit 21da697

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

dev-proxy-plugins/Behavior/RetryAfterPlugin.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ private void UpdateProxyResponse(ProxyRequestArgs e, ThrottlingInfo throttlingIn
106106
})
107107
);
108108
}
109+
else
110+
{
111+
// ProxyUtils.BuildGraphResponseHeaders already includes CORS headers
112+
if (request.Headers.Any(h => h.Name.Equals("Origin", StringComparison.OrdinalIgnoreCase)))
113+
{
114+
headers.Add(new("Access-Control-Allow-Origin", "*"));
115+
headers.Add(new("Access-Control-Expose-Headers", throttlingInfo.RetryAfterHeaderName));
116+
}
117+
}
109118

110119
headers.Add(new(throttlingInfo.RetryAfterHeaderName, throttlingInfo.ThrottleForSeconds.ToString()));
111120

0 commit comments

Comments
 (0)