Skip to content

Update proxying-api-requests-in-development.md #8429

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chybisov
Copy link
Contributor

@chybisov chybisov commented Feb 5, 2020

We should always pass path parameter to app.use and context parameter to proxy, which are almost always the same, except cases mentioned in third Note.

app.use mounts the specified middleware function at the specified path: the middleware function is executed when the base of the requested path matches path.

proxy first parameter specify context (part of url) which then will be checked whether request url has it or not. This is not necessarily with http requests, but will break WebpackDevServer sockjs-node HMR functionality when we try to proxy some of our own websocket requests. Default context is '/' and because all urls has '/', /sockjs-node from WDS also will be proxied, but it shouldn't. http requests work without specifying context because no one else sends http requests.

Related to this comment.

We should always pass path parameter to app.use and context parameter to proxy, which are almost always the same, except cases mentioned in third Note. 

app.use mounts the specified middleware function at the specified path: the middleware function is executed when the base of the requested path matches path.

proxy first parameter specify context (part of url) which then will be checked whether request url has it or not. This is not necessarily with http requests, but will break WebpackDevServer sockjs-node HMR functionality when we try to proxy some of our own websocket requests. Default context is '/' and because all urls has '/', /sockjs-node from WDS also will be proxied, but it shouldn't. http requests work without specifying context because no one else sends http requests.
@chybisov
Copy link
Contributor Author

Updated http-proxy-middleware imports as of v1.0.0

@chybisov
Copy link
Contributor Author

chybisov commented Mar 21, 2020

@iansu @amyrlam @mindhaq please consider to merge. Similar PR #8515 was merged, while this one was earlier and has more improvements. Thank you!

@amyrlam amyrlam removed their request for review August 24, 2020 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants