首页 > 解决方案 > 即使没有设置 url,Spartacus 元标记也会被配置覆盖

问题描述

我在 CCv2 环境中设置了 Spartacus v2 (Hybris 2005)。我目前面临的问题是元标记的内容<meta name="occ-backend-base-url" content="OCC_BACKEND_BASE_URL_VALUE" />在我的任何环境中都没有被替换。

发生这种情况是因为我需要将 app.module.ts 中的 occ 前缀设置为 hybris 2005:

     backend: {
        occ: {
          prefix: '/occ/v2/'
        }
      }

是否有针对此问题的仅前端解决方案,或者我们是否需要在后端将前缀更改回 /rest/v2?

即使在 backend.occ 数据对象中没有定义 url,但只有前缀,元标记是否会被忽略?

索引.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Spartacusstore</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link rel="manifest" href="manifest.webmanifest">
  <meta name="theme-color" content="#1976d2">
  <meta name="occ-backend-base-url" content="OCC_BACKEND_BASE_URL_VALUE" />
</head>

<body>
  <app-root></app-root>
  <noscript>Please enable JavaScript to continue using this application.</noscript>
</body>
</html>

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { translations, translationChunksConfig } from '@spartacus/assets';
import { B2cStorefrontModule } from '@spartacus/storefront';
import { OccConfig, I18nModule, TranslatePipe } from '@spartacus/core';

const occConfig: OccConfig = { backend: { occ: {} } };
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    B2cStorefrontModule.withConfig({
      backend: {
        occ: {
          prefix: '/occ/v2/'
        }
      },
      checkout: {
        guest: true
      },
      context: {
        currency: ['USD'],
        language: ['en'],
        baseSite: ['electronics-spa']
      },
      i18n: {
        resources: translations,
        chunks: translationChunksConfig,
        fallbackLang: 'en'
      },
      features: {
        level: '2.0'
      },
    }),
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

标签: spartacus-storefront

解决方案


推荐阅读