Skip to content

Commit

Permalink
[Headless SSR Proxy] Fix shape of config object - additional fixes (#992
Browse files Browse the repository at this point in the history
)

* Updated link for performance/caching in headless proxy
* Export ProxyConfig which can be used in the typescript-based app.
* createViewBag returns an object or promise, before it was only promise
  • Loading branch information
illiakovalenko authored Apr 19, 2022
1 parent 0497d69 commit 4097075
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const compression = require('compression');
require('dotenv').config();
const scProxy = require('@sitecore-jss/sitecore-jss-proxy').default;
const config = require('./config');
const cacheMiddleware = require('./cacheMiddleware');
// const cacheMiddleware = require('./cacheMiddleware');

const server = express();
const port = process.env.PORT || 3000;
Expand All @@ -24,7 +24,7 @@ server.use(

/**
* Output caching, can be enabled,
* Read about restrictions here: {@link https://jss.sitecore.com/docs/techniques/performance/caching}
* Read about restrictions here: {@link https://doc.sitecore.com/xp/en/developers/hd/190/sitecore-headless-development/caching-in-headless-server-side-rendering-mode.html}
*/
// server.use(cacheMiddleware());

Expand Down
3 changes: 1 addition & 2 deletions packages/sitecore-jss-proxy/src/ProxyConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ export interface ProxyConfig {
response: ServerResponse,
proxyResponse: IncomingMessage,
layoutServiceData: LayoutServiceData
) => // eslint-disable-next-line @typescript-eslint/ban-types
Promise<object>;
) => Promise<{ [key: string]: unknown }> | { [key: string]: unknown };
/** Hook to alter HTTP headers in a custom way. */
setHeaders?: (
request: IncomingMessage,
Expand Down
2 changes: 2 additions & 0 deletions packages/sitecore-jss-proxy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,3 +575,5 @@ export default function scProxy(
const options = createOptions(renderer, config, parseRouteUrl);
return proxy(options);
}

export { ProxyConfig };

0 comments on commit 4097075

Please sign in to comment.