The URL of a REST API container can be set up in a different container that is equipped with Angular CLI proxy by adding a proxy configuration file to the Angular application. The proxy configuration file should contain a mapping of the API base URL to the target URL of the REST API container.
For example, if the API base URL is http://localhost:3000/api/
and the target URL of the REST API container is http://rest-api-service:8080/
, the proxy configuration file would look like this:
{
"/api/*": {
"target": "http://rest-api-service:8080/",
"secure": false,
"pathRewrite": {
"^/api": ""
},
"changeOrigin": true
}
}
This configuration file tells the Angular CLI proxy to redirect any requests to the /api
endpoint to the target URL of the REST API container.
Once the proxy configuration file is set up, the Angular application can use relative URLs for API requests, and the proxy will redirect those requests to the correct container.
Asked: 2023-07-09 02:36:17 +0000
Seen: 9 times
Last updated: Jul 09 '23