Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions server/vue-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,23 @@ async function render(context) {
}
});

const setCookies = [];
let setCookies = [];

return Promise.all([typesPromise, cookiePromise])
.then(([types, cookieInfo]) => {
// add fetched types to rendering context
context.config.graphqlPossibleTypes = types;
// update cookies in the rendering context with any newly fetched session cookies
context.cookies = Object.assign(context.cookies, cookieInfo.cookies);
// forward any newly fetched 'Set-Cookie' headers
context.setCookies = [...cookieInfo.setCookies];
// collect any newly fetched 'Set-Cookie' headers to send after the render
setCookies = [...cookieInfo.setCookies];
// render the app
return renderer.renderToString(context);
})
.then(html => {
// collect any cookies created during the app render
setCookies.concat(context.setCookies);
const contextSetCookies = context?.setCookies ?? [];
setCookies = [...setCookies, ...contextSetCookies];
// send the final rendered html
return {
html,
Expand All @@ -71,7 +72,8 @@ async function render(context) {
})
.catch(err => {
// collect any cookies created during the app render
setCookies.concat(context.setCookies);
const contextSetCookies = context?.setCookies ?? [];
setCookies = [...setCookies, ...contextSetCookies];
// send the error
return {
error: err,
Expand Down