Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure proxy with Angular 17 (esbuild/vite)

I used to use a proxy with Angular <= 16, using webpack.

Switching to Angular 17 and default esbuild/vite, the proxy configuration does not seem to work anymore.

This configuration used to work:

{
    "/api/*": {
        "target": "http://localhost:8080",
        "secure": false,
        "changeOrigin": true,
        "pathRewrite": {
            "^/api": ""
        }
    }
}

I tried the following two ways to provide the config:

  • ng serve --proxy-config proxy.conf.json
  • Setting proxyConfig in angular.json

In both ways the configuration seems to be ignored.

I'm using Angular (including CLI) 17.0.8 and Node v18.17.0.

Thanks for your help!

I tried to provide the proxy configuration to Angular, expected it to proxy the requests, but the request were not proxied.

like image 805
powerweb Avatar asked Nov 19 '25 07:11

powerweb


1 Answers

Add two ** instead one *

this way:

{
    "/api/**": {
        "target": "http://localhost:8080",
        "secure": false,
        "changeOrigin": true,
        "pathRewrite": {
           "^/api": ""
        }
    }
}
like image 143
Juan David Ochoa Avatar answered Nov 22 '25 02:11

Juan David Ochoa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!