How to make Angulajs and Yii2 REST API on a single web server?

Good day!
Develop an application in Angularjs and Yii2 Rest API.
Now launch the app using webpack on the same machine where you are developing. Yii2 Rest API server is running on nginx on a different machine, therefore in the nginx configuration I had to add the line:
add_header Access-Control-Allow-Origin "http://localhost:4200";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
add_header Access-Control-Allow-Headers "Keep-Alive Content-Type";
add_header Access-Control-Expose-Headers "Content-Type";

to prevent browser wrote CORS error.
Now see the solution of this problem:
REST Api in Yii2 to do this in a separate controller
and assembled AngularJS app to bind to the other controller, for example, SiteController.
Prompt, please according to the questions:
1. Whether my solution for this problem?
2. Where better to do routing in angularjs or yii (now there are studies routing in angularjs)?
June 7th 19 at 14:56
1 answer
June 7th 19 at 14:58
Solution
While made so:
location /url_project/api_v1 {
 root /path_project/api_v1;
 try_files $uri $uri/ $document_root/index.php$is_args$args;
}

 location /url_project {
 root /path_project;
 try_files $uri $uri/ /$document_root/index.html;
 }

Find more questions by tags Web DevelopmentYiiAngular