Search code examples
spartacus-storefront

Spartacus running dev:ssr on multisite not passing requestOrigin from the NgExpressEngineDecorator


I'm running a Spartacus SSR Multisite. This works fine when I'm running yarn build:ssr and yarn serve:ssr. The Spartacus NgExpressEngineDecorator nicely passes the original hostname to the application.

But when I run yarn dev:ssr for debugging purposes, this fails. The SERVER_REQUEST_ORIGIN always returns localhost or 127.0.0.1. https://github.com/SAP/spartacus/blob/develop/core-libs/setup/ssr/engine-decorator/ng-express-engine-decorator.ts#L108

So the baseSite can't be found.

Setting "host" and "publicHost" options on the "serve-ssr" in angular.json doesn't seem to help either. Any ideas how we can solve this issue?

If I have a decent way to debug the multisite SSR, I'd be very happy.


Solution

  • As @Krzysztof Platis mentioned, putting server.set('trust proxy', 'loopback'); in server.ts is what solved my problem