mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 17:35:57 +00:00
fix(nitro): correct issues rendering payload.js
(#466)
This commit is contained in:
parent
a994bec4f3
commit
7f9ef5e13d
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user