Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
kalina559 committed Jul 30, 2024
1 parent db8a4f9 commit 24f451a
Showing 3 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Battleships.Common.GameClasses;
using Battleships.Common.Helpers;
using System.Collections.Generic;

namespace Battleships.AI.Strategies.Heuristics
{
1 change: 0 additions & 1 deletion Battleships.Common/Helpers/GridHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Battleships.Common.GameClasses;
using System.Diagnostics;
using System.Diagnostics.Metrics;

namespace Battleships.Common.Helpers
{
20 changes: 7 additions & 13 deletions Battleships.WebApi/Program.cs
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@
using Battleships.Core.Services;
using Battleships.Services.Interfaces;
using Battleships.WebApi;
using System;
using System.Configuration;

var builder = WebApplication.CreateBuilder(args);

@@ -17,30 +15,27 @@
options.IdleTimeout = TimeSpan.FromMinutes(30);
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
options.Cookie.SameSite = SameSiteMode.None; // Set SameSite to None for cross-site requests
options.Cookie.SecurePolicy = CookieSecurePolicy.Always; // Use Always to ensure cookies are only sent over HTTPS
options.Cookie.SameSite = SameSiteMode.None; // to allow cross-site requests
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;

});

// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// Add CORS policy
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowSpecificOrigin",
builder =>
{
builder.WithOrigins("http://localhost:8080", "https://kalina559.github.io") // Your frontend URL
builder.WithOrigins("http://localhost:8080", "https://kalina559.github.io") // frontend URL
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials(); // Allow credentials
.AllowCredentials();

});
});

// Register application services
builder.Services.AddScoped<IShipLocationService, ShipLocationService>();
builder.Services.AddScoped<IGenerateMoveService, GenerateMoveService>();
builder.Services.AddScoped<IGameStateService, GameStateService>();
@@ -55,7 +50,6 @@
ServiceCollectionSetup.InitializeCosmosClientInstanceAsync(cosmosDbSettings, builder.Services);


// Configure logging
builder.Logging.ClearProviders();
builder.Logging.AddConsole();

@@ -72,10 +66,10 @@

app.UseHttpsRedirection();
app.UseRouting();
app.UseCors("AllowSpecificOrigin"); // Use the specific CORS policy
app.UseSession(); // Ensure this is called before UseAuthorization
app.UseCors("AllowSpecificOrigin");
app.UseSession();
app.UseAuthorization();

app.MapControllers();

app.Run();
app.Run();

0 comments on commit 24f451a

Please sign in to comment.