File tree 1 file changed +8
-4
lines changed
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) {
317
317
// For single page apps, we generally want to fallback to /index.html.
318
318
// However we also want to respect `proxy` for API calls.
319
319
// 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.
321
324
// Modern browsers include text/html into `accept` header when navigating.
322
325
// However API calls like `fetch()` won’t generally accept text/html.
323
326
// If this heuristic doesn’t work well for you, use a custom `proxy` object.
324
327
context : function ( pathname , req ) {
325
328
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 )
329
333
) ;
330
334
} ,
331
335
onProxyReq : proxyReq => {
You can’t perform that action at this time.
0 commit comments