mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
1 parent
362975e49b
commit
5e37a63c5f
1 file changed
+4
-3
@@ -67,9 +67,10 @@ export default (logger, xff, xhost) => async (ctx: KoaContext, next: Next) => {
|
|||||||
|| request.query.noTemplate || !response.template) {
|
|| request.query.noTemplate || !response.template) {
|
||||||
// Send raw data
|
// Send raw data
|
||||||
try {
|
try {
|
||||||
if (typeof response.body === 'object') {
|
if (typeof response.body === 'object' && request.headers['x-hydro-inject']) {
|
||||||
response.body.UiContext = UiContext;
|
const inject = request.headers['x-hydro-inject'].toString().toLowerCase().split(',').map((i) => i.trim());
|
||||||
response.body.UserContext = user;
|
if (inject.includes('uicontext')) response.body.UiContext = UiContext;
|
||||||
|
if (inject.includes('usercontext')) response.body.UserContext = user;
|
||||||
}
|
}
|
||||||
response.body = JSON.stringify(response.body, serializer(false, handler));
|
response.body = JSON.stringify(response.body, serializer(false, handler));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in new issue
Block a user