From 14483684d3ce05a90f76552fd36ca71f9b4ebe07 Mon Sep 17 00:00:00 2001
From: Wesley Ford <wes@wesdevpro.com>
Date: Mon, 27 Nov 2023 15:08:06 -0600
Subject: [PATCH] fix(all): fixed routing and debugging with cmd

---
 src/EducationTrail/EducationTrail.csproj      |  2 -
 src/EducationTrail/Program.cs                 | 12 +++---
 .../Properties/launchSettings.json            | 39 ++++++-------------
 .../appsettings.Production.json               | 16 ++++++++
 src/EducationTrail/appsettings.json           |  9 -----
 5 files changed, 35 insertions(+), 43 deletions(-)
 create mode 100644 src/EducationTrail/appsettings.Production.json
 delete mode 100644 src/EducationTrail/appsettings.json

diff --git a/src/EducationTrail/EducationTrail.csproj b/src/EducationTrail/EducationTrail.csproj
index 4f4c8df..b83fe9e 100644
--- a/src/EducationTrail/EducationTrail.csproj
+++ b/src/EducationTrail/EducationTrail.csproj
@@ -7,8 +7,6 @@
       <NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
       <SpaRoot>ClientApp\</SpaRoot>
       <SpaProxyServerUrl>https://localhost:5002</SpaProxyServerUrl>
-      <!-- <SpaProxyServerUrl Condition="'$(RequiresHttps)' == 'True'">https://localhost:5002</SpaProxyServerUrl>
-      <SpaProxyServerUrl Condition="'$(RequiresHttps)' != 'True'">http://localhost:5002</SpaProxyServerUrl> -->
       <SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand>
       <ImplicitUsings>enable</ImplicitUsings>
     </PropertyGroup>
diff --git a/src/EducationTrail/Program.cs b/src/EducationTrail/Program.cs
index afbb21f..b98ef28 100644
--- a/src/EducationTrail/Program.cs
+++ b/src/EducationTrail/Program.cs
@@ -4,14 +4,16 @@
 
 var app = builder.Build();
 
-app.UseStaticFiles();
-
-app.MapFallbackToFile("index.html");
-
 app.UseHttpsRedirection();
 
 app.UseAuthorization();
 
 app.MapControllers();
 
-app.Run();
+if(app.Environment.IsProduction()) 
+{
+    app.UseStaticFiles();  
+    app.MapFallbackToFile("index.html");
+}
+
+app.Run();
\ No newline at end of file
diff --git a/src/EducationTrail/Properties/launchSettings.json b/src/EducationTrail/Properties/launchSettings.json
index 9c8326f..a9da8ff 100644
--- a/src/EducationTrail/Properties/launchSettings.json
+++ b/src/EducationTrail/Properties/launchSettings.json
@@ -1,29 +1,14 @@
-{
-  "iisSettings": {
-    "windowsAuthentication": false,
-    "anonymousAuthentication": true,
-    "iisExpress": {
-      "applicationUrl": "http://localhost:48063",
-      "sslPort": 0
-    }
-  },
-  "profiles": {
-    "Company.WebApplication1": {
-      "commandName": "Project",
-      "launchBrowser": true,
-      "applicationUrl": "http://localhost:5000",
-      "environmentVariables": {
-        "ASPNETCORE_ENVIRONMENT": "Development",
-        "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
-      }
-    },
-    "IIS Express": {
-      "commandName": "IISExpress",
-      "launchBrowser": true,
-      "environmentVariables": {
-        "ASPNETCORE_ENVIRONMENT": "Development",
-        "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
+{
+    "profiles": {
+      "EducationTrail": {
+        "commandName": "Project",
+        "launchBrowser": true,
+        "applicationUrl": "https://localhost:5001",
+        "environmentVariables": {
+          "ASPNETCORE_ENVIRONMENT": "Development",
+          "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
+        },
+        "isDefault": true
       }
     }
-  }
-}
\ No newline at end of file
+  }
\ No newline at end of file
diff --git a/src/EducationTrail/appsettings.Production.json b/src/EducationTrail/appsettings.Production.json
new file mode 100644
index 0000000..3b79456
--- /dev/null
+++ b/src/EducationTrail/appsettings.Production.json
@@ -0,0 +1,16 @@
+{
+  "AllowedHosts": "*",
+  "Kestrel": {
+    "Endpoints": {
+      "Https": {
+        "Url": "https://localhost:5001"
+      }
+    }
+  },
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/EducationTrail/appsettings.json b/src/EducationTrail/appsettings.json
deleted file mode 100644
index 10f68b8..0000000
--- a/src/EducationTrail/appsettings.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-  "Logging": {
-    "LogLevel": {
-      "Default": "Information",
-      "Microsoft.AspNetCore": "Warning"
-    }
-  },
-  "AllowedHosts": "*"
-}