Closed
Description
What problem does this docs change solve?
When setting devServer.proxy
to a string value, proxying only happens for XHR requests, which can be confusing:
- configure
devServer.proxy
to'http://localhost:3000'
; - open
http://localhost:8080/api/users
from the address bar in the browser;- expectation: the request is proxyed to
http://localhost:3000/api/users
, the browser shows the API response; - reality: the browser shows the app (it loads
index.html
, because ofwebpack-dev-server
'shistoryApiFallback
);
- expectation: the request is proxyed to
- the same request works fine (gets proxyed and returns the API response) if it's done using
XMLHttpRequest
(axios
) orfetch
.
If setting devServer.proxy
explicitly to { '^/api': { target: 'http://localhost:3000' } }
, the same URL - http://localhost:8080/api/users
- will work as expected both when opened from the address bar and when loading it from an XHR request.
What should the docs change look like?
Make this distinction clear in the docs, as users might set devServer.proxy
to a string, test that it works by loading an API URL from the browser's address bar, see the app instead of the API response, and conclude that it doesn't work.