Created by: jamesblight
This is an attempt to resolve #1780 (closed) by using the proxy handling of Webpack dev server to allow multiple proxies to be added to package.json. Supported config options can be found here: https://webpack.github.io/docs/webpack-dev-server.html#proxy
The changes are compatible with the previous method and behaviour of providing a simple proxy string
{
"proxy": "http://localhost:4000"
}
I've tested the following proxy scenarios:
Proxy as a string
Expected behaviour is maintained. Requests that accept text/html always fallback to /index.html
Proxy as an object in the form:
{
"proxy": { "<context>": { "target": "<url>" } }
}
All matching requests are proxied to the target. This includes requests with a 'text/html' Accept Header. It is up to the user to bypass those requests manually in the config.
No proxy specified in package.json
All requests fallback to /index.html
This change relies on Webpack dev server being updated to handle the external websocket upgrade as CRA no longer adds the proxy middleware.
This is a step towards #671 (closed) #1702 (closed) Should be solved by adding a custom oauth callback proxy
EDIT: Webpack dev server v2.4.2 handles the external websocket upgrade for all proxies. webpack/webpack-dev-server#843
Please provide any feedback.