Empty OCC baseUrl breaks SSR mode
See original GitHub issueOverview
In case when we run Spartacus in the same domain as the API we don’t want to set OCC URL as API endpoints should be referenced with relative URLs (not the absolute).
Steps to Reproduce
- Have Spartacus and backend on the same domain
- Remove the
occ.baseUrl
option from your config - Check that the page doesn’t work
The application is crashed with the following error:
ERROR TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
at subscribeTo (/Users/artem.zur/Documents/Projects/storefront/dist/storefront/server/main.js:131192:15)
at innerSubscribe (/Users/artem.zur/Documents/Projects/storefront/dist/storefront/server/main.js:274679:93)
at CatchSubscriber.error (/Users/artem.zur/Documents/Projects/storefront/dist/storefront/server/main.js:118063:109)
at SwitchMapSubscriber.notifyError (/Users/artem.zur/Documents/Projects/storefront/dist/storefront/server/main.js:274653:26)
at SimpleInnerSubscriber._error (/Users/artem.zur/Documents/Projects/storefront/dist/storefront/server/main.js:274621:21)
at SimpleInnerSubscriber.error (/Users/artem.zur/Documents/Projects/storefront/dist/storefront/server/main.js:105894:18)
at CatchSubscriber.notifyError (/Users/artem.zur/Documents/Projects/storefront/dist/storefront/server/main.js:274653:26)
at SimpleInnerSubscriber._error (/Users/artem.zur/Documents/Projects/storefront/dist/storefront/server/main.js:274621:21)
at SimpleInnerSubscriber.error (/Users/artem.zur/Documents/Projects/storefront/dist/storefront/server/main.js:105894:18)
at Observable._Observable__WEBPACK_IMPORTED_MODULE_0__.Observable.scheduler.schedule.error.error [as _subscribe] (/Users/artem.zur/Documents/Projects/storefront/dist/storefront/server/main.js:273227:100)
Expected behavior
A Spartacus application works without occ.baseUrl
in SRR mode
Environment Details
- Spartacus: *-3.4.1
Additional context
- The issue https://github.com/SAP/spartacus/issues/10436 solved the same problem for Auth flow
- https://angular.io/guide/universal#using-absolute-urls-for-http-data-requests-on-the-server
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
How to configure in Spartacus a different OCC baseUrl in CSR ...
Instead of providing a static config, you can provide a config factory, which takes the PLATFORM_ID and checks whether it is a browser...
Read more >storefrontapp documentation - SAP
occ -configurator-textfield-update-cart-entry-serializer.ts) ... Default value : '[Checkout] Clear Checkout Delivery Mode Fail' ...
Read more >Access Gateway Guide
This value is empty until you have created at least one reverse proxy and it has been assigned to be used for authentication....
Read more >kendo.all.min.js.map - IIS Windows Server
... OACE,kBAAVzB,SAAwBA,OAAOghC,IAAMhhC,OAAS,SAAUihC,EAAIC,EAAIC,IACrEA,GAAMD,OAEV,SAAUnhC,EAAGC,QACVA,OAAO,YAAa,cAAeD,IACrC,WAupCE,MA/oCC,UAAUE,EAAGE,GA4KV ...
Read more >vbt - ALBA.Net
Occ bookings news star, Fes hotel ibis, Zeg fahrrad aachen, Faturar veiculo? ... Open form in add mode access vba, Kwang sung brakes...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@RPisarew @artem-zur Please note that it’s not secure to trust on the raw x-forwarded-… headers! You need to trust the proxy that have set it. See https://expressjs.com/en/guide/behind-proxies.html
For knowing the server request URL or origin you should use the the Spartacus tokens
SERVER_REQUEST_ORIGIN
orSERVER_REQUEST_URL
(see https://sap.github.io/spartacus-docs/server-side-rendering-coding-guidelines/#getting-the-request-url-and-origin). Their resolver function take into account the trusted proxy configured for Express.js. See: https://github.com/SAP/spartacus/blob/ea55840f9119a9ceab8025ef497a2d56cbc03645/core-libs/setup/ssr/engine-decorator/ng-express-engine-decorator.ts#L89-L106Thanks for providing workaround We’ll try to fix this for 4.2. Also evaluate if it needs a backport to 3.x