forked from MDCPS/DamageAssessment_Backend
Updat for CORS Resolution
This commit is contained in:
@ -5,13 +5,18 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System.Reflection;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
// CORS setup to allow requests from any origin.
|
||||
builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => {
|
||||
build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
|
||||
}));
|
||||
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
// Add controller services and API Explorer for endpoint discovery.
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
//builder.Services.AddSwaggerGen();
|
||||
// Add Swagger/OpenAPI documentation support.
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
// Include XML comments from your assembly
|
||||
@ -44,6 +49,9 @@ if (app.Environment.IsDevelopment())
|
||||
}
|
||||
}
|
||||
|
||||
// Enable CORS, authentication, and authorization middleware.
|
||||
app.UseCors("DamageAppCorsPolicy");
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
Reference in New Issue
Block a user