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._configuration = configuration;
this._httpEncoder = httpEncoder; this._httpEncoder = httpEncoder;
this._dbContext = context; this._dbContext = context;
// this._dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
this._cacheManager = cacheManager; this._cacheManager = cacheManager;
this._logger = logger; this._logger = logger;
this._httpContext = httpContext; this._httpContext = httpContext;

View file

@ -62,12 +62,7 @@ namespace Roadie.Api
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
// global cors policy app.UseCors("CORSPolicy");
app.UseCors(x => x
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
app.UseAuthentication(); app.UseAuthentication();
//app.UseSwagger(); //app.UseSwagger();
@ -90,15 +85,15 @@ namespace Roadie.Api
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddCors(options => options.AddPolicy("Cors", builder => services.AddCors(options => options.AddPolicy("CORSPolicy", builder =>
{ {
builder builder
.AllowAnyOrigin() .AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod() .AllowAnyMethod()
.AllowAnyHeader(); .AllowCredentials();
})); }));
services.AddSingleton<ITokenService, TokenService>(); services.AddSingleton<ITokenService, TokenService>();
services.AddSingleton<IHttpEncoder, HttpEncoder>(); services.AddSingleton<IHttpEncoder, HttpEncoder>();

View file

@ -122,5 +122,11 @@ namespace Roadie.Library.Identity
public virtual ICollection<UserQue> UserQues { get; set; } public virtual ICollection<UserQue> UserQues { get; set; }
public virtual ICollection<ApplicationUserRole> UserRoles { 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@ -65,6 +66,15 @@ namespace Roadie.Library.Identity
this.RecentlyPlayedLimit = 20; this.RecentlyPlayedLimit = 20;
this.RandomReleaseLimit = 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>();
} }
} }
} }