Hi
We are having problems connecting SignalR to the public MVC page and are getting the following error
We have successfully been using SignalR for our Blazor WASM backend (hosted as static website in Azure) so we know all about how SignalR should work (or we thought at least).
We have been trying all kinds versions of CORS settings in HttpApi.Host without luck
This didn´t do anything (now we are just using app.UseCors()
)
app.UseCors(x => x
.AllowAnyMethod()
.AllowAnyHeader()
.SetIsOriginAllowed(origin => true)
.AllowCredentials());
Is there a documentation or some other steps that we might be missing for for connecting with signalR in MVC public web app?
- ABP Framework version: 7.0.2
- UI type: MVC
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated: yes
8 Answer(s)
-
0
You are using wildcard ('*') with
.AllowCredentials
. You need to whitelist the origins.You can configure CORS in publicwebdev app as:
context.Services.AddCors(options => { options.AddDefaultPolicy(builder => { builder .WithOrigins("https://eventstreamingapidev.azurewebsites.net") .WithAbpExposedHeaders() .SetIsOriginAllowedToAllowWildcardSubdomains() .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); }); });
-
0
Hi @gterdem, thanks for the answer
We have been trying to use this without luck. Is there something more we need to do? There is some puzzle missing..
-
0
Did you also add https://eventstreamingpublicwebdev.azurewebsites.net to https://eventstreamingapidev.azurewebsites.net CORS origins?
Can you try removing
.AllowCredentials();
and test again? -
0
the question has been reopened due to the owner's request
-
0
-
0
Did you try removing
.AllowCredentials();
and tested again?Do you still get the same error? Did you check the appsettings.json file is overridden correctly on deployment?
-
0
-
0
Yes, if you can check the module ConfigureServices method that has CORS configuration, you are basically missing it.
You may also forget to override it on production environment aswell.