diff --git a/CSharp/OidcSamples/OidcSamples.TrafficPoliceApi/Startup.cs b/CSharp/OidcSamples/OidcSamples.TrafficPoliceApi/Startup.cs index 99ba32e..e4cd056 100644 --- a/CSharp/OidcSamples/OidcSamples.TrafficPoliceApi/Startup.cs +++ b/CSharp/OidcSamples/OidcSamples.TrafficPoliceApi/Startup.cs @@ -34,6 +34,15 @@ namespace OidcSamples.TrafficPoliceApi { JwtSecurityTokenHandler.DefaultInboundClaimTypeMap["sub"] = "sub"; + services.AddCors(options => + { + options.AddPolicy(name: "Default", + builder => + { + builder.AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod(); + }); + }); + services.AddDbContext(options => options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection")) .UseSnakeCaseNamingConvention() @@ -87,6 +96,8 @@ namespace OidcSamples.TrafficPoliceApi app.UseRouting(); + app.UseCors("Default"); + // 2. Enable authentication middleware app.UseAuthentication(); app.UseAuthorization(); diff --git a/React/traffic-police/src/pages/components/VehiclesMain.js b/React/traffic-police/src/pages/components/VehiclesMain.js index 2fb39dd..4179afe 100644 --- a/React/traffic-police/src/pages/components/VehiclesMain.js +++ b/React/traffic-police/src/pages/components/VehiclesMain.js @@ -16,44 +16,7 @@ const VehiclesMain = () => { const history = useHistory(); - // Initial state must be null ** Temporary ** - const [vehicleData, setVehicleData] = useState([ - { - id: Math.floor(Math.random() * 200) + 1, - color: "White", - model: "Toyota Camry", - licensePlate: "14324235", - type: 2, - }, - { - id: Math.floor(Math.random() * 200) + 1, - color: "Black", - model: "Honda Accord", - licensePlate: "8765658", - type: 1, - }, - { - id: Math.floor(Math.random() * 200) + 1, - color: "Beige", - model: "Toyota Corolla", - licensePlate: "235464", - type: 2, - }, - { - id: Math.floor(Math.random() * 200) + 1, - color: "Grey", - model: "Toyota Yaris", - licensePlate: "1878767", - type: 2, - }, - { - id: Math.floor(Math.random() * 200) + 1, - color: "White", - model: "Toyota Camry", - licensePlate: "9956443", - type: 1, - }, - ]); + const [vehicleData, setVehicleData] = useState(null); useEffect(() => { getVehicles();