fix(vue-renderer): decode route path for payload.js (#9494)

[release]
This commit is contained in:
Daniel Roe 2021-06-28 15:28:46 +01:00 committed by GitHub
parent 35c6ac411d
commit 82e4c2dc5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,7 @@ import { format } from 'util'
import fs from 'fs-extra' import fs from 'fs-extra'
import consola from 'consola' import consola from 'consola'
import { TARGETS, urlJoin } from '@nuxt/utils' import { TARGETS, urlJoin } from '@nuxt/utils'
import { parsePath, withoutTrailingSlash } from 'ufo' import { decode, parsePath, withoutTrailingSlash } from 'ufo'
import devalue from '@nuxt/devalue' import devalue from '@nuxt/devalue'
import { createBundleRenderer } from 'vue-server-renderer' import { createBundleRenderer } from 'vue-server-renderer'
import BaseRenderer from './base' import BaseRenderer from './base'
@ -210,7 +210,7 @@ export default class SSRRenderer extends BaseRenderer {
// Page level payload.js (async loaded for CSR) // Page level payload.js (async loaded for CSR)
const payloadPath = urlJoin(url, 'payload.js') const payloadPath = urlJoin(url, 'payload.js')
const payloadUrl = urlJoin(staticAssetsBase, payloadPath) const payloadUrl = urlJoin(staticAssetsBase, payloadPath)
const routePath = withoutTrailingSlash(parsePath(url).pathname) const routePath = withoutTrailingSlash(decode(parsePath(url).pathname))
const payloadScript = `__NUXT_JSONP__("${routePath}", ${devalue({ data, fetch, mutations })});` const payloadScript = `__NUXT_JSONP__("${routePath}", ${devalue({ data, fetch, mutations })});`
staticAssets.push({ path: payloadPath, src: payloadScript }) staticAssets.push({ path: payloadPath, src: payloadScript })
preloadScripts.push(payloadUrl) preloadScripts.push(payloadUrl)