Ask Your Question
2

In what way can the url of a rest api container be set up in a different container that is equipped with Angular cli proxy?

asked 2023-07-09 02:36:17 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-07-09 02:44:01 +0000

lalupa gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-09 02:36:17 +0000

Seen: 9 times

Last updated: Jul 09 '23