File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -317,15 +317,19 @@ function prepareProxy(proxy, appPublicFolder) {
317317 // For single page apps, we generally want to fallback to /index.html.
318318 // However we also want to respect `proxy` for API calls.
319319 // So if `proxy` is specified as a string, we need to decide which fallback to use.
320- // We use a heuristic: if request `accept`s text/html, we pick /index.html.
320+ // We use a heuristic: We want to proxy all the requests that are not meant
321+ // for static assets and as all the requests for static assets will be using
322+ // `GET` method, we can proxy all non-`GET` requests.
323+ // For `GET` requests, if request `accept`s text/html, we pick /index.html.
321324 // Modern browsers include text/html into `accept` header when navigating.
322325 // However API calls like `fetch()` won’t generally accept text/html.
323326 // If this heuristic doesn’t work well for you, use a custom `proxy` object.
324327 context : function ( pathname , req ) {
325328 return (
326- mayProxy ( pathname ) &&
327- req . headers . accept &&
328- req . headers . accept . indexOf ( 'text/html' ) === - 1
329+ req . method !== 'GET' ||
330+ ( mayProxy ( pathname ) &&
331+ req . headers . accept &&
332+ req . headers . accept . indexOf ( 'text/html' ) === - 1 )
329333 ) ;
330334 } ,
331335 onProxyReq : proxyReq => {
You can’t perform that action at this time.
0 commit comments