cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Smart Edit Shows Loading when Early Login is Enabled in Spartacus

Yashwanth
Advisor
Advisor
0 Kudos
2,023

Hi

I have enabled early login for my B2B site. I have not done any customization and using Hybris 2211 Version and Spartacus 5.2 V

Smart Edit will always be in a loading state as below. If I remove Early Login import it works fine. Is there anything else I need to do here?

Only Changes are done in the spartacus-configuration.module.ts file . I have added below smartedit configuration

 storefrontPreviewRoute: 'cx-preview',
        allowOrigin: 'localhost:9002',

and Early Login configuration

imports: [

    ConfigModule.withConfig({
      routing: {
        /* ... */
        protected : true,
        routes: {
          contact: {
            paths: ['contact'],
            protected: false, // make the contact route public
          },
          register: {
            protected: false, // make the register route protected by overriding the `protected: false` configuration in `default-routing-config.ts`
          },
        },
      },
    }),
  ],

Below is the Complete File

import { NgModule } from '@angular/core';
import { translationChunksConfig, translations } from '@spartacus/assets';
import {
  ConfigModule,
  FeaturesConfig,
  I18nConfig,
  OccConfig,
  provideConfig,
  SiteContextConfig,
} from '@spartacus/core';
import { defaultB2bOccConfig } from '@spartacus/setup';
import { SmartEditConfig } from '@spartacus/smartedit/root';
import {
  defaultCmsContentProviders,
  layoutConfig,
  mediaConfig,
} from '@spartacus/storefront';

@NgModule({
  declarations: [],
  imports: [
    ConfigModule.withConfig({
      routing: {
        /* ... */
        protected : true,
        routes: {
          contact: {
            paths: ['contact'],
            protected: false, // make the contact route public
          },
          register: {
            protected: false, // make the register route protected by overriding the `protected: false` configuration in `default-routing-config.ts`
          },
        },
      },
    }),
  ],
  providers: [
    provideConfig(layoutConfig),
    provideConfig(mediaConfig),
    ...defaultCmsContentProviders,
    provideConfig(<OccConfig>{
      backend: {
        occ: {
          baseUrl: 'https://localhost:9002',
        },
      },
    }),
    provideConfig(<SiteContextConfig>{
      context: {
        urlParameters: ['baseSite', 'language', 'currency'],
        baseSite: ['powertools-spa'],
        currency: ['USD', 'GBP'],
      },
    }),
    provideConfig(<I18nConfig>{
      i18n: {
        resources: translations,
        chunks: translationChunksConfig,
        fallbackLang: 'en',
      },
    }),
    provideConfig(<FeaturesConfig>{
      features: {
        level: '5.2',
      },
    }),
    provideConfig(defaultB2bOccConfig),
    provideConfig(<SmartEditConfig>{
      smartEdit: {
        storefrontPreviewRoute: 'cx-preview',
        allowOrigin: 'localhost:9002',
      },
    }),
  ],
})
export class SpartacusConfigurationModule {}

sap commerce cloud - Missing Perspective Toolbar in SmartEdit in SPARTACUS 5.2 Version - Stack Overf...


Regards
Yashwanth

Accepted Solutions (1)

Accepted Solutions (1)

Yashwanth
Advisor
Advisor
0 Kudos

I tried to debug on why it was not working in Early login scenario.

I have identified the root cause is because that when the homepage loads in the smartEdit. The navigation will be " https://localhost:9002/cx-preview

Since cx-preview is not excluded from the protected list and call goes on a loop somewhere between AuthGuard and it never completes .

Hence if someone faces the same issue. Try the below solution as it worked for me

Exclude "cx-preview" from the protected list as shown below

 cxpreview: {
            paths: ['cx-preview'],
            protected: false, // make the cx-preview smart edit route public
          },
alexswalker
Discoverer
0 Kudos

Can you clarify where you placed this please? We have the same problem, but don't receive any console errors or network failures.

Yashwanth
Advisor
Advisor
0 Kudos

You need to add it to the Spartacus configuration module file below inside the routes object.

imports: [
    ConfigModule.withConfig({
      routing: {
        /* ... */
        protected : true,
        routes: {
          contact: {
            paths: ['contact'],
            protected: false, // make the contact route public
          },
          register: {
            protected: false, // make the register route protected by overriding the `protected: false` configuration in `default-routing-config.ts`
          },
        },
      },
    }),
  ],

Answers (2)

Answers (2)

former_member826219
Discoverer
0 Kudos

Hello guys. I had the same issue with spartacus 6.0. I cheked spartacus-configuration.module.ts and remove not my allowOrigin: I kept local and dev env and Now it's working fine.

provideConfig({
backend: occConfig.backend,
smartEdit: {
storefrontPreviewRoute: 'cx-preview',
// TODO: adjust origins as necessary
allowOrigin: 'localhost:9002, *.*.my.dev.enviroment',
},
safin
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi

I think this is a bug in composable storefront 5.2, you can try composable storefront 5.1, it should work.

Hopefully it can help you a little.

Thanks

Yashwanth
Advisor
Advisor
0 Kudos

I have added my solution which worked for me in the comment. I tried in the Spartacus 6.0 also and OOTB did not worked. I have to make custom changes