Skip to content

Commit

Permalink
feat: enhance option to overwrite URL for ICM in express server (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi authored Aug 31, 2020
1 parent 2188fa0 commit edf07dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/guides/ssr-startup.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Only empty strings count as inactive.
| **Debug** :warning: | TRUST_ICM | any | use this if ICM is deployed with an insecure certificate |
| | LOGGING | any | enable extra log output |
| **Hybrid Approach** | SSR_HYBRID | any | enable running PWA and ICM in [Hybrid Mode](../concepts/hybrid-approach.md) |
| | PROXY_ICM | any | proxy ICM via `/INTERSHOP` (enabled if SSR_HYBRID is active) |
| | PROXY_ICM | any \| URL | proxy ICM via `/INTERSHOP` (enabled if SSR_HYBRID is active) |
| **Third party** | GTM_TOKEN | string | token for Google Tag Manager |
| | SENTRY_DSN | string | Sentry DSN URL for using Sentry Error Monitor |

Expand Down
5 changes: 4 additions & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ export function app() {
if (html) {
let newHtml: string;
if (process.env.PROXY_ICM && req.get('host')) {
newHtml = html.replace(new RegExp(ICM_BASE_URL, 'g'), `${req.protocol}://${req.get('host')}`);
newHtml = html.replace(
new RegExp(ICM_BASE_URL, 'g'),
process.env.PROXY_ICM.startsWith('http') ? process.env.PROXY_ICM : `${req.protocol}://${req.get('host')}`
);
}
res.status(res.statusCode).send(newHtml || html);
} else {
Expand Down

0 comments on commit edf07dc

Please sign in to comment.