-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Chore] Remove deprecations - update sxa (#1781)
- Loading branch information
1 parent
0d84c70
commit d9175e0
Showing
4 changed files
with
89 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 49 additions & 49 deletions
98
packages/create-sitecore-jss/src/templates/node-headless-ssr-proxy/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
import express from 'express'; | ||
import compression from 'compression'; | ||
import 'dotenv/config'; | ||
import scProxy from '@sitecore-jss/sitecore-jss-proxy'; | ||
import { config } from './config'; | ||
//import { cacheMiddleware } from './cacheMiddleware'; | ||
|
||
const server = express(); | ||
const port = process.env.PORT || 3000; | ||
|
||
// enable gzip compression for appropriate file types | ||
server.use(compression()); | ||
|
||
// turn off x-powered-by http header | ||
server.settings['x-powered-by'] = false; | ||
|
||
// Serve static app assets from local /dist folder | ||
server.use( | ||
'/dist', | ||
express.static('dist', { | ||
fallthrough: false, // force 404 for unknown assets under /dist | ||
}) | ||
); | ||
|
||
/** | ||
* Output caching, can be enabled, | ||
* Read about restrictions here: {@link https://doc.sitecore.com/xp/en/developers/hd/22/sitecore-headless-development/caching-in-headless-server-side-rendering-mode.html} | ||
*/ | ||
//server.use(cacheMiddleware()); | ||
|
||
server.use((req, _res, next) => { | ||
// because this is a proxy, all headers are forwarded on to the Sitecore server | ||
// but, if we SSR we only understand how to decompress gzip and deflate. Some | ||
// modern browsers would send 'br' (brotli) as well, and if the Sitecore server | ||
// supported that (maybe via CDN) it would fail SSR as we can't decode the Brotli | ||
// response. So, we force the accept-encoding header to only include what we can understand. | ||
if (req.headers['accept-encoding']) { | ||
req.headers['accept-encoding'] = 'gzip, deflate'; | ||
} | ||
|
||
next(); | ||
}); | ||
|
||
// For any other requests, we render app routes server-side and return them | ||
server.use('*', scProxy(config.serverBundle.renderView, config, config.serverBundle.parseRouteUrl)); | ||
|
||
server.listen(port, () => { | ||
console.log(`server listening on port ${port}!`); | ||
}); | ||
import express from 'express'; | ||
import compression from 'compression'; | ||
import 'dotenv/config'; | ||
import scProxy from '@sitecore-jss/sitecore-jss-proxy'; | ||
import { config } from './config'; | ||
//import { cacheMiddleware } from './cacheMiddleware'; | ||
|
||
const server = express(); | ||
const port = process.env.PORT || 3000; | ||
|
||
// enable gzip compression for appropriate file types | ||
server.use(compression()); | ||
|
||
// turn off x-powered-by http header | ||
server.settings['x-powered-by'] = false; | ||
|
||
// Serve static app assets from local /dist folder | ||
server.use( | ||
'/dist', | ||
express.static('dist', { | ||
fallthrough: false, // force 404 for unknown assets under /dist | ||
}) | ||
); | ||
|
||
/** | ||
* Output caching, can be enabled, | ||
* Read about restrictions here: {@link https://doc.sitecore.com/xp/en/developers/hd/22/sitecore-headless-development/caching-in-headless-server-side-rendering-mode.html} | ||
*/ | ||
//server.use(cacheMiddleware()); | ||
|
||
server.use((req, _res, next) => { | ||
// because this is a proxy, all headers are forwarded on to the Sitecore server | ||
// but, if we SSR we only understand how to decompress gzip and deflate. Some | ||
// modern browsers would send 'br' (brotli) as well, and if the Sitecore server | ||
// supported that (maybe via CDN) it would fail SSR as we can't decode the Brotli | ||
// response. So, we force the accept-encoding header to only include what we can understand. | ||
if (req.headers['accept-encoding']) { | ||
req.headers['accept-encoding'] = 'gzip, deflate'; | ||
} | ||
|
||
next(); | ||
}); | ||
|
||
// For any other requests, we render app routes server-side and return them | ||
server.use('*', scProxy(config.serverBundle.renderView, config, config.serverBundle.parseRouteUrl)); | ||
|
||
server.listen(port, () => { | ||
console.log(`server listening on port ${port}!`); | ||
}); |