Skip to content

Commit

Permalink
fix(nitro): correct issues rendering payload.js (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Sep 1, 2021
1 parent 8c8918b commit 584a14d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/runtime/app/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/server/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit 584a14d

Please sign in to comment.