Skip to content

Commit 7da8e93

Browse files
author
Сергей Трегуб
committed
Configure CORS to use with SignalR
1 parent ffb105f commit 7da8e93

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

ProjectTemplates/ReferenceProject/Startup.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,15 @@ public void Configure(IApplicationBuilder app, ILogger<Startup> logger)
146146

147147
// See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#cross-origin-resource-sharing-cors-and-preflight-requests
148148
app.UseCors(builder => builder
149-
.AllowAnyOrigin()
150149
.AllowAnyMethod()
151-
.AllowAnyHeader());
152-
153-
app
154-
.UseOptionsVerbHandler() // Options verb handler must be added after CORS. See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#cross-origin-resource-sharing-cors-and-preflight-requests
155-
.UseSwaggerWithOptions(); // Check out Configuration/MiddlewareConfig.cs/UseSwaggerWithOptions to do actual configuration. See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#documenting-api
150+
.AllowAnyHeader()
151+
.AllowAnyOrigin() // <-- Comment this line out and uncomment two lines below to use with SignalR
152+
/*.AllowCredentials()
153+
.SetIsOriginAllowed(origin => true)*/
154+
);
155+
156+
app.UseOptionsVerbHandler() // Options verb handler must be added after CORS. See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#cross-origin-resource-sharing-cors-and-preflight-requests
157+
.UseSwaggerWithOptions(); // Check out Configuration/MiddlewareConfig.cs/UseSwaggerWithOptions to do actual configuration. See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#documenting-api
156158

157159
app.UseEndpoints(endpoints =>
158160
{

0 commit comments

Comments
 (0)