From 71a3df8443b5166114dc7c87b60797d7f0f04d39 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 11 Jan 2021 10:11:00 +0000 Subject: [PATCH] fix(vue-app): don't remove req/res/query unless in full static mode (#8611) closes #7965 --- packages/vue-app/template/server.js | 4 +++- packages/vue-app/template/utils.js | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/vue-app/template/server.js b/packages/vue-app/template/server.js index 0fe341f0a3..5beb11fb55 100644 --- a/packages/vue-app/template/server.js +++ b/packages/vue-app/template/server.js @@ -80,9 +80,11 @@ export default async (ssrContext) => { <% } %> // Remove query from url is static target - if (process.static && ssrContext.url) { + <% if (isFullStatic) { %> + if (ssrContext.url) { ssrContext.url = ssrContext.url.split('?')[0] } + <% } %> // Public runtime config ssrContext.nuxt.config = ssrContext.runtimeConfig.public // Create the app definition and the instance (created for each request) diff --git a/packages/vue-app/template/utils.js b/packages/vue-app/template/utils.js index ad54b9650f..d156f77817 100644 --- a/packages/vue-app/template/utils.js +++ b/packages/vue-app/template/utils.js @@ -184,12 +184,14 @@ export async function setContext (app, context) { env: <%= JSON.stringify(env) %><%= isTest ? '// eslint-disable-line' : '' %> } // Only set once - if (!process.static && context.req) { + <% if (!isFullStatic) { %> + if (context.req) { app.context.req = context.req } - if (!process.static && context.res) { + if (context.res) { app.context.res = context.res } + <% } %> if (context.ssrContext) { app.context.ssrContext = context.ssrContext }