From c0bc89083dadda4f5b22d1b1cdcdfb9800496dc9 Mon Sep 17 00:00:00 2001 From: "kham.vilaythong" Date: Wed, 13 May 2026 18:22:17 +1000 Subject: [PATCH] put in fixed error in appsetting.cs does not have other key --- API/FamilyTreeAPI/Entities/AppSettings.cs | 4 +- API/FamilyTreeAPI/Program.cs | 15 ++++- .../Repository/UserServiceRepository.cs | 2 +- API/FamilyTreeAPI/familytree_service.service | 2 +- API/FamilyTreeAPI/familytreeapp.conf | 61 +++++++++---------- 5 files changed, 46 insertions(+), 38 deletions(-) diff --git a/API/FamilyTreeAPI/Entities/AppSettings.cs b/API/FamilyTreeAPI/Entities/AppSettings.cs index ac9972e..6bae7f5 100644 --- a/API/FamilyTreeAPI/Entities/AppSettings.cs +++ b/API/FamilyTreeAPI/Entities/AppSettings.cs @@ -4,9 +4,9 @@ public class AppSettings { public string Secret { get; set; } public string SQLConnectionString { get; set; } - public string LoginWebAPI { get; set; } + public string ImageFolder { get; set; } - public string ClientURL { get; set; } + public string ImportFolder { get; set; } } /* diff --git a/API/FamilyTreeAPI/Program.cs b/API/FamilyTreeAPI/Program.cs index 6f41e17..de36b5f 100644 --- a/API/FamilyTreeAPI/Program.cs +++ b/API/FamilyTreeAPI/Program.cs @@ -24,9 +24,18 @@ services.AddEndpointsApiExplorer(); services.AddSwaggerGen(); var appSettingsSection = builder.Configuration.GetSection("AppSettings"); -services.Configure(appSettingsSection); -var appSettings = appSettingsSection.Get(); -var key = Encoding.ASCII.GetBytes(appSettings.Secret); +string skey = ""; +if (appSettingsSection == null) +{ + skey = builder.Configuration.GetValue("AppSettings:SecretKey"); +} +else +{ + services.Configure(appSettingsSection); + var appSettings = appSettingsSection.Get(); + skey = appSettings.Secret; +} +var key = Encoding.ASCII.GetBytes(skey); services.AddAuthentication(x => { diff --git a/API/FamilyTreeAPI/Repository/UserServiceRepository.cs b/API/FamilyTreeAPI/Repository/UserServiceRepository.cs index 6fcf5a3..d6fab40 100644 --- a/API/FamilyTreeAPI/Repository/UserServiceRepository.cs +++ b/API/FamilyTreeAPI/Repository/UserServiceRepository.cs @@ -146,7 +146,7 @@ public class UserServiceRepository : IUserService AuthenticateResponse retval = null; string error = "user name is not in DB or user Name profile is not generic"; int statuscode = 0; - string webAPIUrl = _appSettings.LoginWebAPI; + string webAPIUrl = "_appSettings.LoginWebAPI"; //KCO, D204KCO //now check the adminuser table //ward clerk diff --git a/API/FamilyTreeAPI/familytree_service.service b/API/FamilyTreeAPI/familytree_service.service index 9ace7f5..02a06d8 100644 --- a/API/FamilyTreeAPI/familytree_service.service +++ b/API/FamilyTreeAPI/familytree_service.service @@ -2,7 +2,7 @@ Description=ASP.NET Core Web App running on Ubuntu [Service] WorkingDirectory=/var/www/familytree/api - ExecStart=/usr/bin/dotnet /var/www/fadmilytree/api/FamilyTreeAPI.dll + ExecStart=/usr/bin/dotnet /var/www/familytree/api/FamilyTreeAPI.dll Restart=always # Restart service after 10 seconds if the dotnet service crashes: RestartSec=10 diff --git a/API/FamilyTreeAPI/familytreeapp.conf b/API/FamilyTreeAPI/familytreeapp.conf index caa6a3c..d9924ef 100644 --- a/API/FamilyTreeAPI/familytreeapp.conf +++ b/API/FamilyTreeAPI/familytreeapp.conf @@ -1,35 +1,34 @@ -server { - listen 80; - server_name://yourdomain.com # your actaul subdomain + +#make sure in nginx.conf has include module.d/*.conf inside http block one. + server { + listen 80; #make nginx out side listen 82; + location / { + proxy_pass http://127.0.0.1:5000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection keep-alive; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /familytreeui/ { + root /var/www/familytree; #path must exist like /var/www/familytree/familytreeui and /var/www/familytree/api folder. + index index.html + try_files $uri $uri/ /index.html; + } + + + # Optional: Cache static assets for better performance + location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { + expires 30d; + add_header Cache-Control "public"; + } - #root /var/www/familytree/familytreeui; #path to your build files - #index index.html - - location / { - proxy_pass http://127.0.0.1:5000; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection keep-alive; - proxy_set_header Host $host; - proxy_cache_bypass $http_upgrade; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } - - location /familytreeui/ { - root /var/www/familytree; #path must exist like /var/www/familytree/familytreeui and /var/www/familytree/api folder. - index index.html - try_files $uri $uri/ /index.html; - } - # Optional: Cache static assets for better performance - location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { - expires 30d; - add_header Cache-Control "public"; - } - - error_page 404 /index.html; -} + error_page 404 /index.html; # put in /etc/nginx/sites-availalble/familytreeapp.conf # link to enable -# $) sudo ln -s /etc/nginx/sites-availalble/familytreeapp.conf /etc/nginx/sites-enabled/ \ No newline at end of file +# $) sudo ln -s /etc/nginx/sites-availalble/familytreeapp.conf /etc/nginx/sites-enabled/ + }