fix(nitro): correct issues rendering payload.js (#466)

This commit is contained in:
Daniel Roe 2021-09-01 19:08:09 +01:00 committed by GitHub
parent a994bec4f3
commit 7f9ef5e13d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -55,7 +55,7 @@ export async function renderMiddleware (req, res: ServerResponse) {
let isPayloadReq = false
if (url.startsWith(STATIC_ASSETS_BASE) && url.endsWith(PAYLOAD_JS)) {
isPayloadReq = true
url = url.substr(STATIC_ASSETS_BASE.length, url.length - STATIC_ASSETS_BASE.length - PAYLOAD_JS.length)
url = url.substr(STATIC_ASSETS_BASE.length, url.length - STATIC_ASSETS_BASE.length - PAYLOAD_JS.length) || '/'
}
// Initialize ssr context

View File

@ -6,6 +6,7 @@ import { getAsset, readAsset } from '#static'
const METHODS = ['HEAD', 'GET']
const PUBLIC_PATH = process.env.PUBLIC_PATH // Default: /_nuxt/
const TWO_DAYS = 2 * 60 * 60 * 24
const STATIC_ASSETS_BASE = process.env.NUXT_STATIC_BASE + '/' + process.env.NUXT_STATIC_VERSION
// eslint-disable-next-line
export default async function serveStatic(req, res) {
@ -27,7 +28,7 @@ export default async function serveStatic(req, res) {
}
if (!asset) {
if (id.startsWith(PUBLIC_PATH)) {
if (id.startsWith(PUBLIC_PATH) && !id.startsWith(STATIC_ASSETS_BASE)) {
throw createError({
statusMessage: 'Cannot find static asset ' + id,
statusCode: 404