Skip to content

proxy-config does only rewrite request when not available locally #6408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
toaditoad opened this issue May 22, 2017 · 3 comments
Closed

proxy-config does only rewrite request when not available locally #6408

toaditoad opened this issue May 22, 2017 · 3 comments

Comments

@toaditoad
Copy link

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

ng --version
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / â–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.0.4
node: 6.10.3
os: win32 x64
@angular/common: 2.4.10
@angular/compiler: 2.4.10
@angular/compiler-cli: 2.4.10
@angular/core: 2.4.10
@angular/forms: 2.4.10
@angular/http: 2.4.10
@angular/platform-browser: 2.4.10
@angular/platform-browser-dynamic: 2.4.10
@angular/router: 3.4.10
@angular/upgrade: 2.4.10
@angular/cli: 1.0.4

As also shown in many other issues and SO posts, I try to create a proxy and redirect requests from my frontend (localhost:4200) to my backend (localhost:5001).

proxy.conf.json

{
  "/assets/*": {
    "target": "http://localhost:5001/",
    "secure": false,
    "logLevel": "debug",
    "pathRewrite": {"^/assets": ""},
    "changeOrigin": false
  }
}

I successfully run my application with ng serve --proxy-config src\environments\proxy.conf.json. When I access e.g. http://localhost:4200/assets//api/v1/sites/1, it gets rewritten as expected to http://localhost:5001/api/v1/sites/1. However, when requesting http://localhost:4200/assets//api/v1/vehicles, it does not work. They only obvious difference is that the resource vehicles exists under http://localhost:4200 whereas sites/1 does not. When I delete vehicles, the request gets also rewritten.

Is this the expected behaviour: Only rewrite the request if the resource is not available under the original host?

@filipesilva
Copy link
Contributor

We forward that file to the webpack-dev-server proxy functionality, which in turn fowards it to http-proxy-middleware. At first blush it seems to be intended, yes. You can read more about it in https://webpack.js.org/configuration/dev-server/#devserver-proxy.

@toaditoad
Copy link
Author

Thanks for confirming that.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants