Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Pass requestingSiteId to redirectToFn, withContent middleware #815

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
6 changes: 5 additions & 1 deletion packages/marko-web/middleware/with-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ module.exports = ({

const additionalInput = buildContentInput({ req });
const content = await loader(apollo, { id, additionalInput, queryFragment: loaderQueryFragment });
const requestingSiteId = req.app.locals.config.website('id');

// set the route kind
setRouteKind(res, { kind: 'content', type: content.type });
const redirectTo = isFn(redirectToFn) ? redirectToFn({ content }) : content.redirectTo;
const redirectTo = isFn(redirectToFn) ? redirectToFn({
content,
requestingSiteId,
}) : content.redirectTo;
const path = isFn(pathFn) ? pathFn({ content }) : get(content, 'siteContext.path');

if (redirectTo) {
Expand Down
Loading