CORS setup for API get detail preflights

This commit is contained in:
Steven Hildreth 2018-12-01 18:11:55 -06:00
parent 6c3d92d49d
commit d6c5fbe7dc
4 changed files with 25 additions and 13 deletions

View file

@ -80,6 +80,7 @@ namespace Roadie.Api.Services
this._configuration = configuration;
this._httpEncoder = httpEncoder;
this._dbContext = context;
// this._dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
this._cacheManager = cacheManager;
this._logger = logger;
this._httpContext = httpContext;

View file

@ -62,13 +62,8 @@ namespace Roadie.Api
app.UseDeveloperExceptionPage();
}
// global cors policy
app.UseCors(x => x
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
app.UseCors("CORSPolicy");
app.UseAuthentication();
//app.UseSwagger();
//app.UseSwaggerUI(c =>
@ -90,14 +85,14 @@ namespace Roadie.Api
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options => options.AddPolicy("Cors", builder =>
services.AddCors(options => options.AddPolicy("CORSPolicy", builder =>
{
builder
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowAnyHeader();
.AllowCredentials();
}));
services.AddSingleton<ITokenService, TokenService>();
@ -111,7 +106,7 @@ namespace Roadie.Api
));
services.AddDbContextPool<IRoadieDbContext, RoadieDbContext>(
options => options.UseMySql(this._configuration.GetConnectionString("RoadieDatabaseConnection")
options => options.UseMySql(this._configuration.GetConnectionString("RoadieDatabaseConnection")
));
services.AddIdentity<ApplicationUser, ApplicationRole>()

View file

@ -122,5 +122,11 @@ namespace Roadie.Library.Identity
public virtual ICollection<UserQue> UserQues { get; set; }
public virtual ICollection<ApplicationUserRole> UserRoles { get; set; }
//public ICollection<ChatMessage> ChatMessages { get; set; }
//public ICollection<Collection> Collections { get; set; }
//public ICollection<Submission> Submission { get; set; }
}
}

View file

@ -1,4 +1,5 @@
using Roadie.Library.Enums;
using Roadie.Library.Data;
using Roadie.Library.Enums;
using System;
using System.Collections.Generic;
using System.Text;
@ -64,7 +65,16 @@ namespace Roadie.Library.Identity
this.IsPrivate = false;
this.RecentlyPlayedLimit = 20;
this.RandomReleaseLimit = 20;
// Collections = new HashSet<Collection>();
Playlists = new HashSet<Playlist>();
Requests = new HashSet<Request>();
Submissions = new HashSet<Submission>();
UserQues = new HashSet<UserQue>();
ArtistRatings = new HashSet<UserArtist>();
ReleaseRatings = new HashSet<UserRelease>();
TrackRatings = new HashSet<UserTrack>();
}
}
}