Skip to content

Commit 152ebae

Browse files
javascript(angular): add proxy to the angular.json configuration (#2708)
1 parent 1eb722f commit 152ebae

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

aspire-samples

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit c7edffcc113e08856995c17f0a3d9b4bd072c942

docs/get-started/build-aspire-apps-with-nodejs.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,13 @@ There are several key modifications from the original Angular template. The firs
148148

149149
The .NET Aspire app host sets the `services__weatherapi__http__0` environment variable, which is used to resolve the "weatherapi" service endpoint. The preceding configuration proxies HTTP requests that start with `/api` to the target URL specified in the environment variable.
150150

151-
The second update is to the _package.json_ file. This file is used to configure the Angular client to run on a different port than the default port. This is achieved by using the `PORT` environment variable, and the `run-script-os` npm package to set the port.
151+
Then include the proxy file to in the _angular.json_ file.
152+
Update the `serve` target to include the `proxyConfig` option, referencing to the created _proxy.conf.js_ file.
153+
The Angular CLI will now use the proxy configuration while serving the Angular client app.
154+
155+
:::code language="javascript" source="~/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/angular.json" range="59-73" highlight="13":::
156+
157+
The third update is to the _package.json_ file. This file is used to configure the Angular client to run on a different port than the default port. This is achieved by using the `PORT` environment variable, and the `run-script-os` npm package to set the port.
152158

153159
:::code language="json" source="~/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/package.json":::
154160

0 commit comments

Comments
 (0)