elsa-workflows / elsa-workflows/elsa-core

[Elsa 3.x] Elsa Server in Blazor server app

Open
#6,574 2 comments 0 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

I'm trying to expose Elsa Server API in a Blazor server app, but `localhost:/elsa/api` always give 404... what's wrong with my configuration?

```
//[omiss using]

var builder = WebApplication.CreateBuilder(args);

builder.Host.UseSerilog((hostingContext, services, loggerConfiguration) =>
{
loggerConfiguration
.ReadFrom.Configuration(hostingContext.Configuration)
.ReadFrom.Services(services)
.Enrich.FromLogContext()
.WriteTo.Console();
});

builder.Services.AddRazorPages();
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();

builder.Services.AddDbContext(options =>
{
// omissis
}, ServiceLifetime.Transient);

// omissis

builder.Services
.AddElsa(elsa => elsa
.UseIdentity(identity =>
{
identity.TokenOptions = options => options.SigningKey = "large-signing-key-for-signing-JWT-tokens";
identity.UseAdminUserProvider();
})
.UseDefaultAuthentication()
.UseWorkflowManagement(management => management.UseEntityFrameworkCore(ef => ef.UsePostgreSql(builder.Configuration.GetConnectionString("PgConnection"))))
.UseWorkflowRuntime(runtime => runtime.UseEntityFrameworkCore(ef => ef.UsePostgreSql(builder.Configuration.GetConnectionString("PgConnection"))))
.UseScheduling()
.UseJavaScript()
.UseLiquid()
.UseCSharp()
.UseHttp(http => http.ConfigureHttpOptions = options => builder.Configuration.GetSection("Elsa:Server").Bind(options))
.UseWorkflowsApi()
.UseWorkflows()
.UseRealTimeWorkflows()
.AddActivitiesFrom()
.AddWorkflowsFrom()
);

builder.Services.AddCors(cors => cors
.AddDefaultPolicy(policy => policy
.AllowAnyOrigin() // For demo purposes only. Use a specific origin instead.
.AllowAnyHeader()
.AllowAnyMethod()
.WithExposedHeaders("x-elsa-workflow-instance-id")));

builder.Services.AddHealthChecks();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseCors();

app.UseHttpsRedirection();

app.UseAuthentication();
app.UseAuthorization();
app.UseAntiforgery();

app.MapStaticAssets();
app.MapRazorComponents()
.AddInteractiveServerRenderMode();

app.UseWorkflowsApi();
app.UseWorkflows();

app.Run();
```

Thanks in advance for any hints!

Contributor guide

Open the contributing guide

Research direction

Review the shown Elsa service registration and request-pipeline setup, especially the UseWorkflowsApi and UseWorkflows calls. Reproduce the request to /elsa/api and inspect how the configured Elsa server options affect route exposure. Done means identifying the configuration or integration issue and confirming that the intended Elsa API endpoint no longer returns 404.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.