Skip to content

Commit

Permalink
Fix not configuring Origins setion to support any cross-domain requests
Browse files Browse the repository at this point in the history
  • Loading branch information
fanliang11 committed Nov 5, 2019
1 parent 4ae7084 commit be43a8d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/Surging.ApiGateway/Configs/gatewaySettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"TokenEndpointPath": "api/oauth2/token",
"CacheMode": "MemoryCache", //MemoryCache or gateway.Redis save token
"AccessPolicy": {
"Origins": [ "http://127.0.0.1:1927", "http://localhost:927" ],
"AllowAnyHeader": true,
"AllowAnyMethod": true
},
Expand Down
1 change: 1 addition & 0 deletions src/Surging.ApiGateway/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
app.UseCors(builder =>
{
var policy = Core.ApiGateWay.AppConfig.Policy;
if(policy.Origins !=null)
builder.WithOrigins(policy.Origins);
if (policy.AllowAnyHeader)
builder.AllowAnyHeader();
Expand Down
1 change: 1 addition & 0 deletions src/Surging.Core/Surging.Core.Stage/StageModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public override void Initialize(ApplicationInitializationContext context)
{
context.Builder.UseCors(builder =>
{
if(policy.Origins!=null)
builder.WithOrigins(policy.Origins);
if (policy.AllowAnyHeader)
builder.AllowAnyHeader();
Expand Down

0 comments on commit be43a8d

Please sign in to comment.