|
@@ -80,7 +80,7 @@ builder.Services.AddControllers(options =>
|
|
{
|
|
{
|
|
//add filter by instance
|
|
//add filter by instance
|
|
options.Filters.Add(new InputValidationActionFilter());
|
|
options.Filters.Add(new InputValidationActionFilter());
|
|
- //add filter By the type
|
|
|
|
|
|
+ //add filter By the type
|
|
options.Filters.Add(typeof(InputValidationActionFilter));
|
|
options.Filters.Add(typeof(InputValidationActionFilter));
|
|
});
|
|
});
|
|
//disable default model validation, because we handle this in InputValidationActionFilter and LoggingMiddleware.
|
|
//disable default model validation, because we handle this in InputValidationActionFilter and LoggingMiddleware.
|
|
@@ -110,7 +110,9 @@ builder.Services.AddSignalR(options =>
|
|
{
|
|
{
|
|
options.EnableDetailedErrors = true;
|
|
options.EnableDetailedErrors = true;
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+builder.Services.AddCors(options => {
|
|
|
|
+ options.AddPolicy("CORSPolicy", builder => builder.AllowAnyMethod().AllowAnyHeader().AllowCredentials().SetIsOriginAllowed((hosts) => true));
|
|
|
|
+});
|
|
builder.Services.AddSwaggerGen(swagger =>
|
|
builder.Services.AddSwaggerGen(swagger =>
|
|
{
|
|
{
|
|
//This is to apply global headers for all requests
|
|
//This is to apply global headers for all requests
|
|
@@ -119,7 +121,7 @@ builder.Services.AddSwaggerGen(swagger =>
|
|
//This is to export enums to front
|
|
//This is to export enums to front
|
|
swagger.SchemaFilter<EnumSchemaFilter>();
|
|
swagger.SchemaFilter<EnumSchemaFilter>();
|
|
|
|
|
|
- //This is to generate the Default UI of Swagger Documentation
|
|
|
|
|
|
+ //This is to generate the Default UI of Swagger Documentation
|
|
swagger.SwaggerDoc("v1", new OpenApiInfo
|
|
swagger.SwaggerDoc("v1", new OpenApiInfo
|
|
{
|
|
{
|
|
Version = "v1",
|
|
Version = "v1",
|
|
@@ -131,7 +133,7 @@ builder.Services.AddSwaggerGen(swagger =>
|
|
d => (d.ActionDescriptor as ControllerActionDescriptor)?.ControllerName + (d.ActionDescriptor as ControllerActionDescriptor)?.ActionName
|
|
d => (d.ActionDescriptor as ControllerActionDescriptor)?.ControllerName + (d.ActionDescriptor as ControllerActionDescriptor)?.ActionName
|
|
);
|
|
);
|
|
|
|
|
|
- // To Enable authorization using Swagger (JWT)
|
|
|
|
|
|
+ // To Enable authorization using Swagger (JWT)
|
|
swagger.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
|
|
swagger.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
|
|
{
|
|
{
|
|
Name = "Authorization",
|
|
Name = "Authorization",
|
|
@@ -173,13 +175,13 @@ app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MTWorkHR.AP
|
|
|
|
|
|
app.UseRouting(); // <-- Add UseRouting() here
|
|
app.UseRouting(); // <-- Add UseRouting() here
|
|
|
|
|
|
-app.UseCors(x => x
|
|
|
|
- .WithOrigins("https://api.mtwork.com", "https://mtworkhrclient.azurewebsites.net", "http://localhost:4200", "https://www.mtwork.com") // Allowed origins without trailing slash
|
|
|
|
- .AllowAnyMethod()
|
|
|
|
- .AllowAnyHeader()
|
|
|
|
- .AllowCredentials() // Allows credentials
|
|
|
|
-);
|
|
|
|
-
|
|
|
|
|
|
+//app.UseCors(x => x
|
|
|
|
+// .WithOrigins("https://api.mtwork.com", "https://mtworkhrclient.azurewebsites.net", "http://localhost:4200", "https://www.mtwork.com") // Allowed origins without trailing slash
|
|
|
|
+// .AllowAnyMethod()
|
|
|
|
+// .AllowAnyHeader()
|
|
|
|
+// .AllowCredentials() // Allows credentials
|
|
|
|
+//);
|
|
|
|
+app.UseCors("CORSPolicy");
|
|
|
|
|
|
|
|
|
|
|
|
|