Search code examples
spartacus-storefront

data-smartedit-allow-origin set during build process


for smartedit to work, the spartacus documentaion states, it is necessary need to provide the webApplicationInjector.js script within the index.html.

Additionally, the value 'data-smartedit-allow-origin' needs to be set with a list of smartedit instances.

Like this:

<script id="smartedit-injector" src="webApplicationInjector.js" data-smartedit-allow-origin="localhost:9002"></script>

But what is the best practise for Prod-Environments? Is there a build process to override this value with the specific environment?

Because I don't want to put a list with all the possible environments, including localhost into the index.html.

Any help would be appreciated.

Many thanks, Julian


Solution

  • you can setup several environment properties in the angular environment model, see https://angular.io/guide/build or more information on that. Then you need to add the smartedit injector dynamically, taking the environment properties into account. You could with this approach also lazily load the script, as it's not needed for the normal visitor. You can read about our intend here at https://github.com/SAP/cloud-commerce-spartacus-storefront/issues/3805#issuecomment-543090561.