You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+85-52Lines changed: 85 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# BFF security architecture using ASP.NET Core and nx Angular standalone
1
+
# BFF security architecture using ASP.NET Core and Angular CLI
2
2
3
3
[](https://github.com/damienbod/bff-aspnetcore-angular/actions/workflows/dotnet.yml)[](https://github.com/damienbod/bff-aspnetcore-angular/actions/workflows/azure-webapps-dotnet-core.yml)[](https://github.com/damienbod/bff-aspnetcore-angular/blob/main/LICENSE)
4
4
@@ -7,25 +7,55 @@
7
7
The ASP.NET Core project is setup to run in development and production. In production, it uses the Angular production build deployed to the wwwroot. In development, it uses MS YARP reverse proxy to forward requests.
8
8
9
9
> [!IMPORTANT]
10
-
> In production, the Angular nx project is built into the **wwwroot** of the .NET project.
10
+
> In production, the Angular CLI project is built into the **wwwroot** of the .NET project.
Configure the YARP reverse proxy to match the Angular nx URL. This is only required in development. I always use HTTPS in development and the port needs to match the Angular nx developement env.
14
+
Configure the YARP reverse proxy to match the Angular CLI URL. This is only required in development. I always use HTTPS in development and the port needs to match the Angular CLI developement env.
15
15
16
16
> [!IMPORTANT]
17
17
> In a real Angular project, the additional dev routes need to be added so that the __dev refresh__ works!
18
18
19
19
```json
20
20
"UiDevServerUrl": "https://localhost:4201",
21
-
"ReverseProxy": {
21
+
"ReverseProxy": {
22
22
"Routes": {
23
23
"assets": {
24
24
"ClusterId": "cluster1",
25
25
"Match": {
26
26
"Path": "assets/{**catch-all}"
27
27
}
28
28
},
29
+
"angularfsdev": {
30
+
"ClusterId": "cluster1",
31
+
"Match": {
32
+
"Path": "@fs/{**catch-all}"
33
+
}
34
+
},
35
+
"angularngdev": {
36
+
"ClusterId": "cluster1",
37
+
"Match": {
38
+
"Path": "@ng/{**catch-all}"
39
+
}
40
+
},
41
+
"vitedev": {
42
+
"ClusterId": "cluster1",
43
+
"Match": {
44
+
"Path": "@vite/{**catch-all}"
45
+
}
46
+
},
47
+
"wssvite": {
48
+
"ClusterId": "cluster1",
49
+
"Match": {
50
+
"Path": "/",
51
+
"QueryParameters": [
52
+
{
53
+
"Name": "token",
54
+
"Mode": "Exists"
55
+
}
56
+
]
57
+
}
58
+
},
29
59
"routealljs": {
30
60
"ClusterId": "cluster1",
31
61
"Match": {
@@ -44,12 +74,6 @@ Configure the YARP reverse proxy to match the Angular nx URL. This is only requi
44
74
"Path": "/src_{nomatterwhat}_ts.js"
45
75
}
46
76
},
47
-
"signalr": {
48
-
"ClusterId": "cluster1",
49
-
"Match": {
50
-
"Path": "/ng-cli-ws"
51
-
}
52
-
},
53
77
"webpacknodesrcmap": {
54
78
"ClusterId": "cluster1",
55
79
"Match": {
@@ -74,69 +98,77 @@ Configure the YARP reverse proxy to match the Angular nx URL. This is only requi
74
98
}
75
99
```
76
100
77
-
## Setup Angular nx
101
+
## Setup Angular CLI
78
102
79
-
Add the certificates to the nx project for example in the **/certs** folder
103
+
Add the certificates to the CLI project for example in the **/certs** folder
> When creating a new Angular nx project, it adds git files as well, delete these as this is not required.
149
+
> When creating a new Angular CLI project, it adds git files as well, delete these as this is not required.
117
150
118
151
## Prerequisites
119
152
120
153
Node >= v24.10.0
121
154
122
155
```cmd
123
-
npm add --global nx
124
156
npm install @angular/cli -g latest
125
157
npm install --force
126
158
npm run build
127
159
```
128
160
129
161
## Setup development
130
162
131
-
The development environment is setup to use the default tools for each of the tech stacks. Angular nx is used like recommended. I use Visual Studio code. A YARP reverse proxy is used to integrate the Angular development into the backend application.
163
+
The development environment is setup to use the default tools for each of the tech stacks. Angular CLI is used like recommended. I use Visual Studio code. A YARP reverse proxy is used to integrate the Angular development into the backend application.
> Always run in HTTPS, both in development and production
137
169
138
170
```
139
-
nx serve --ssl
171
+
ng serve --ssl
140
172
```
141
173
142
174
## Azure App Registration setup
@@ -205,7 +237,7 @@ The client secret or client certificate needs to be setup, see Microsoft Entra I
205
237
Start the Angular project from the **ui** folder
206
238
207
239
```
208
-
nx serve --ssl
240
+
ng serve --ssl
209
241
```
210
242
211
243
Start the ASP.NET Core project from the **server** folder
@@ -218,7 +250,7 @@ Or just open Visual Studio and run the solution.
218
250
219
251
## github actions build
220
252
221
-
Github actions is used for the DevOps. The build pipeline builds both the .NET project and the Angular nx project using npm. The two projects are built in the same step because the UI project is built into the wwwroot of the server project.
253
+
Github actions is used for the DevOps. The build pipeline builds both the .NET project and the Angular CLI project using npm. The two projects are built in the same step because the UI project is built into the wwwroot of the server project.
222
254
223
255
```yaml
224
256
@@ -236,27 +268,28 @@ jobs:
236
268
237
269
steps:
238
270
239
-
- uses: actions/checkout@v3
271
+
- uses: actions/checkout@v4
240
272
- name: Setup .NET
241
-
uses: actions/setup-dotnet@v3
273
+
uses: actions/setup-dotnet@v4
242
274
with:
243
-
dotnet-version: 8.0.x
275
+
dotnet-version: 9.0.x
244
276
245
277
- name: Restore dependencies
246
278
run: dotnet restore
247
279
248
280
- name: npm setup
249
281
working-directory: ui
250
-
run: npm install
282
+
run: npm install --force
251
283
252
-
- name: ui-nx-build
284
+
- name: ui-angular-cli-build
253
285
working-directory: ui
254
286
run: npm run build
255
287
256
288
- name: Build
257
289
run: dotnet build --no-restore
258
290
- name: Test
259
291
run: dotnet test --no-build --verbosity normal
292
+
260
293
```
261
294
262
295
## github actions Azure deployment
@@ -271,15 +304,15 @@ deployment test server: https://bff-angular-aspnetcore.azurewebsites.net
0 commit comments