diff --git a/packages/gatsby/cache-dir/app.js b/packages/gatsby/cache-dir/app.js index 3676dd72be5e0..312b5e641bdff 100644 --- a/packages/gatsby/cache-dir/app.js +++ b/packages/gatsby/cache-dir/app.js @@ -121,14 +121,13 @@ apiRunnerAsync(`onClientEntry`).then(() => { const rootElement = document.getElementById(`___gatsby`) + const focusEl = document.getElementById(`gatsby-focus-wrapper`) const renderer = apiRunner( `replaceHydrateFunction`, undefined, // Client only pages have any empty body so we just do a normal // render to avoid React complaining about hydration mis-matches. - document.getElementById(`___gatsby`).children.length === 0 - ? ReactDOM.render - : ReactDOM.hydrate + focusEl && focusEl.children.length > 0 ? ReactDOM.hydrate : ReactDOM.render )[0] let dismissLoadingIndicator diff --git a/packages/gatsby/src/utils/dev-ssr/develop-html-route.ts b/packages/gatsby/src/utils/dev-ssr/develop-html-route.ts index 9953f1627892e..4a3b8f2596673 100644 --- a/packages/gatsby/src/utils/dev-ssr/develop-html-route.ts +++ b/packages/gatsby/src/utils/dev-ssr/develop-html-route.ts @@ -10,13 +10,13 @@ export const route = ({ app, program, store }): any => app.get(`*`, async (req, res, next) => { trackFeatureIsUsed(`GATSBY_EXPERIMENTAL_DEV_SSR`) - const pathObj = findPageByPath(store.getState(), req.path) + const pathObj = findPageByPath(store.getState(), decodeURI(req.path)) if (!pathObj) { return next() } - await appendPreloadHeaders(req.path, res) + await appendPreloadHeaders(pathObj.path, res) const htmlActivity = report.phantomActivity(`building HTML for path`, {}) htmlActivity.start() @@ -152,7 +152,7 @@ export const route = ({ app, program, store }): any => node.js, it errored.
${req.path}
${pathObj.path}
${error.filename}