LoginSignup
13
10

More than 5 years have passed since last update.

Angular-cliのproxy設定

Posted at

Angular-cliを使っているプロジェクトで、フロントとAPIのローカル開発サーバーを分けていて、フロント側からAPIを呼ぶ場合の設定方法のメモ

  1. proxy設定ファイルを書く
  2. proxy設定ファイルを指定してng serveする

1. proxy設定ファイルを書く

proxy.conf.json
{
  "/api": {
    "target": "http://localhost:8080",
    "secure": false
  }
}

2. proxy設定ファイルを指定してng serveする

package.json
{
  
  "scripts": {
    "start": "ng serve --proxy-config proxy.conf.json"
  },
  
}
$ npm start

参考

Proxy To Backend

13
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
10