Currently, I have a project set up using the VS 2022 ASP.NET Core with Angular template.
The project itself is working well, but I am facing a challenge in trying to integrate the Angular app with the .NET Core's appsettings.json
file for configuration purposes. My goal is to have one shared file for ease of use and deployment.
When looking at the file structure of the deployed project, it appears as follows:
- Main Deployment Folder
api.exe
(along with other framework files)appsettings.json
wwwroot
folderassets
folderindex.html
(and all other Angular files)
Initially, I attempted creating an Angular service to access the config from a file following guidance provided in this answer here.
However, I realized that I couldn't directly point to the appsettings.json
file located above the wwwroot
directory, as it was not being served in the same manner and thus inaccessible.
I could potentially utilize the build settings in the angular.json
to include the appsettings file, but this approach would lead to managing two config files once again.
While some examples demonstrate serving config settings through an API call, I am hesitant to pursue this option and would prefer to stick to a file-based approach.
My primary questions revolve around:
Is there a way to create a service in the Angular app that resides in the
wwwroot
folder and can directly access theappsettings.json
file in the parent directory without serving it?Would it be viable to consider relocating the
appsetttings.json
down into thewwwroot
folder to enable the Angular app's access, and subsequently modifying the
in the API to incorporate this new location forWebApplication.CreateBuilder(args)
appsettings.json
?
Your insights and suggestions are greatly appreciated!