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
You can serve your Angular CLI application with the `ng serve` command.
4
+
This will compile your application, skip unnecessary optimizations, start a devserver, and automatically rebuild and live reload any subsequent changes.
5
+
You can stop the server by pressing `Ctrl+C`.
6
+
7
+
`ng serve` only executes the builder for the `serve` target in the default project as specified in `angular.json`.
8
+
While any builder can be used here, the most common (and default) builder is `@angular-devkit/build-angular:dev-server`.
9
+
10
+
You can determine which builder is being used for a particular project by looking up the `serve` target for that project.
11
+
12
+
<docs-codelanguage="json">
13
+
14
+
{
15
+
"projects": {
16
+
"my-app": {
17
+
"architect": {
18
+
// `ng serve` invokes the Architect target named `serve`.
This page discusses usage and options of `@angular-devkit/build-angular:dev-server`.
33
+
34
+
## Proxying to a backend server
35
+
36
+
Use [proxying support](https://webpack.js.org/configuration/dev-server/#devserverproxy) to divert certain URLs to a backend server, by passing a file to the `--proxy-config` build option.
37
+
For example, to divert all calls for `http://localhost:4200/api` to a server running on `http://localhost:3000/api`, take the following steps.
38
+
39
+
1. Create a file `proxy.conf.json` in your project's `src/` folder.
40
+
1. Add the following content to the new proxy file:
41
+
42
+
<docs-codelanguage="json">
43
+
44
+
{
45
+
"/api": {
46
+
"target": "http://localhost:3000",
47
+
"secure": false
48
+
}
49
+
}
50
+
51
+
</docs-code>
52
+
53
+
1. In the CLI configuration file, `angular.json`, add the `proxyConfig` option to the `serve` target:
1. To run the development server with this proxy configuration, call `ng serve`.
75
+
76
+
Edit the proxy configuration file to add configuration options; following are some examples.
77
+
For a detailed description of all options, refer to the [webpack DevServer documentation](https://webpack.js.org/configuration/dev-server/#devserverproxy) when using `@angular-devkit/build-angular:browser`, or the [Vite DevServer documentation](https://vite.dev/config/server-options#server-proxy) when using `@angular-devkit/build-angular:browser-esbuild` or `@angular-devkit/build-angular:application`.
78
+
79
+
NOTE: If you edit the proxy configuration file, you must relaunch the `ng serve` process to make your changes effective.
80
+
81
+
## `localhost` resolution
82
+
83
+
As of Node version 17, Node will _not_ always resolve `http://localhost:<port>` to `http://127.0.0.1:<port>`
84
+
depending on each machine's configuration.
85
+
86
+
If you get an `ECONNREFUSED` error using a proxy targeting a `localhost` URL,
87
+
you can fix this issue by updating the target from `http://localhost:<port>` to `http://127.0.0.1:<port>`.
88
+
89
+
See [the `http-proxy-middleware` documentation](https://github.com/chimurai/http-proxy-middleware#nodejs-17-econnrefused-issue-with-ipv6-and-localhost-705)
Copy file name to clipboardExpand all lines: adev-ja/src/content/tools/cli/serve.md
+25-25Lines changed: 25 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
-
# Serving Angular apps for development
1
+
# 開発用にAngularアプリケーションを配信する
2
2
3
-
You can serve your Angular CLI application with the `ng serve` command.
4
-
This will compile your application, skip unnecessary optimizations, start a devserver, and automatically rebuild and live reload any subsequent changes.
Use [proxying support](https://webpack.js.org/configuration/dev-server/#devserverproxy) to divert certain URLs to a backend server, by passing a file to the `--proxy-config` build option.
37
-
For example, to divert all calls for `http://localhost:4200/api` to a server running on `http://localhost:3000/api`, take the following steps.
@@ -71,20 +71,20 @@ For example, to divert all calls for `http://localhost:4200/api` to a server run
71
71
72
72
</docs-code>
73
73
74
-
1.To run the development server with this proxy configuration, call `ng serve`.
74
+
1.このプロキシ設定で開発サーバーを実行するには、`ng serve`を呼び出します。
75
75
76
-
Edit the proxy configuration file to add configuration options; following are some examples.
77
-
For a detailed description of all options, refer to the [webpack DevServer documentation](https://webpack.js.org/configuration/dev-server/#devserverproxy) when using `@angular-devkit/build-angular:browser`, or the [Vite DevServer documentation](https://vite.dev/config/server-options#server-proxy) when using `@angular-devkit/build-angular:browser-esbuild` or `@angular-devkit/build-angular:application`.
See [the `http-proxy-middleware` documentation](https://github.com/chimurai/http-proxy-middleware#nodejs-17-econnrefused-issue-with-ipv6-and-localhost-705)
0 commit comments