question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty OCC baseUrl breaks SSR mode

See original GitHub issue

Overview

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

  1. Have Spartacus and backend on the same domain
  2. Remove the occ.baseUrl option from your config
  3. 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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Platonncommented, Oct 29, 2021

@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_ORIGINor SERVER_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-L106

2reactions
Xymmercommented, Oct 25, 2021

Thanks for providing workaround We’ll try to fix this for 4.2. Also evaluate if it needs a backport to 3.x

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found