diff --git a/packages/gatsby/cache-dir/loader.js b/packages/gatsby/cache-dir/loader.js index ec1a387065e67..8dc50983320b6 100644 --- a/packages/gatsby/cache-dir/loader.js +++ b/packages/gatsby/cache-dir/loader.js @@ -887,7 +887,16 @@ export class ProdLoader extends BaseLoader { } // check if html file exist using HEAD request: // if it does we should navigate to it instead of showing 404 - return doFetch(rawPath, `HEAD`).then(req => { + + // OLD CODE + + // return doFetch(rawPath, `HEAD`).then(req => { + + // NEW FIX: include pathPrefix + const prefixedPath = __PATH_PREFIX__ + ? __PATH_PREFIX__ + rawPath + : rawPath + return doFetch(prefixedPath, `HEAD`).then(req => { if (req.status === 200) { // page (.html file) actually exist (or we asked for 404 ) // returning page resources status as errored to trigger