2

I want to use proxy config in angular-cli

this is my file:

{
    "/api/server": {
        "target": "http://other-site/server",
        "secure": false,
        "logLevel": "debug",
        "pathRewrite": { "^/api/server": "" },
        "changeOrigin": true
    },
    "/api/group": {
        "target": "http://other-site/group",
        "secure": false,
        "logLevel": "debug",
        "pathRewrite": { "^/api/group": "" },
        "changeOrigin": true
    },
    "/api/group/activate": {
        "target": "http://other-site/group/activate",
        "secure": false,
        "logLevel": "debug",
        "pathRewrite": { "^/api/group/activate": "" },
        "changeOrigin": true
    } 
}

it works for me , but i need a other effective solution ( juste remove pattern /api and concatinate with target , for example;

 change "/api/server" to "http://other-site/server" ...etc

i am trying with the code below, but doesn't work

{
    "/api": {
        "target": "http://other-site/",
        "secure": false,
        "logLevel": "debug",
        "pathRewrite": {"^/api" : ""},
        "changeOrigin": true
    },
}

1 Answer 1

2

use pattern "/api/*" ,Try with this:

{
    "/api/*": {
        "target": "http://other-site",
        "secure": false,
        "logLevel": "debug",
        "pathRewrite": { "^/api": "" },
        "changeOrigin": true
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.