Skip to content

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

Open
chybisov wants to merge 2 commits into
react:mainfrom
chybisov:patch-1
Open

Update proxying-api-requests-in-development.md#8429
chybisov wants to merge 2 commits into
react:mainfrom
chybisov:patch-1

Conversation

@chybisov

@chybisov chybisov commented Feb 5, 2020

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

@chybisov

chybisov commented Mar 21, 2020

Copy link
Copy Markdown
Contributor Author

@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