enter image description hereHi everyone my application's Backend in ASP.Net Core 2.0 and Frontend in React Web, I just implemented SignalR But due to issue am not able to create the connection between Client and Server
Error: OPTIONS http://XXXX.XXXX.XXX/chathub/negotiate 405 (Method Not Allowed) XXXX.XXX.XXX/:1 Failed to load http://XXX.XXX.XXX.227/XXXX/chathub/negotiate: Response to the enter image description herepreflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://XX.XXX.XX.XXX:8017' is therefore not allowed access.
Startup File:
services.AddSignalR();
services.AddCors(options =>
{
options.AddPolicy(DefaultCorsPolicyName, builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
Even I also tried with Origin
services.AddCors(options =>
{
options.AddPolicy(DefaultCorsPolicyName, builder =>
builder.WithOrigins("http://XXX.XXX.XXX")
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
app.UseSignalR(route =>
{
route.MapHub<ChatHub>("/chathub");
});
app.UseCors(DefaultCorsPolicyName); //Enable CORS!
Please help me am stuck with this issue
Thanks,