CORS Issue
See original GitHub issueI’m running the AspnetCore Monolith Dashboard sample.
Workflow:,
This problem happens in the HttpReponse Activity, the HttpEndpoint works fine
I’m getting an error on the client which I can’t catch in the server, I think the problem happens in:
Elsa.Activities.Http -> WriteHttpResponse -> OnExecuteAsync(ActivityExecutionContext context)
It seems that response.WriteAsync
fires some background thread that fails at some point but the exception is not caught:
/// <summary>
/// The headers to send along with the response.
/// </summary>
[ActivityProperty(Hint = "Additional headers to write.", UIHint = ActivityPropertyUIHints.Json)]
public HttpResponseHeaders? ResponseHeaders { get; set; }
protected override async ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
{
var httpContext = _httpContextAccessor.HttpContext ?? new DefaultHttpContext();
var response = httpContext.Response;
...
var bodyText = Content;
if (!string.IsNullOrWhiteSpace(bodyText))
{
try
{
await response.WriteAsync(bodyText, context.CancellationToken);
await Task.Delay(5000); <--CLIENT FAILS HERE
Console.WriteLine("Delay End");
}
catch(Exception ex)
{
var z = ex;
}
}
return Done();
}
The API function has not returned when the client already fails:
Client only says “Unknown Backend Error, Status = 0”
The workflow instances are created and Finished OK
This doesn’t happen if the call is made from the browser, so it has to be CORS related
I’m using Angular 10, tried in a clean empty project, no credentials, no extra headers in the http call
(English is not my primary language, sorry for the errors)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
I think it was the order of the Http request pipeline config, I moved
app.UseCors()
to the top and it workedStartup.cs
Sorry, I closed this issue by mistake