SAP Spartacus页面fake Url的防御机制 - not found页面的显示逻辑

SAP Spartacus里的路由机制共同有4种:
When Spartacus is launched, the route is handled by the router logic. There are 4 different types of routing that will be evaluated:

(1) the route should be handled by a custom router path; the customer has added hard-coded routes, and we should prioritise those.
(2) the route is either a PLP or PDP
(3) the route is a CMS content page
(4) the route is unknown (404 not found)

When an incorrect URL is passed to Spartacus, it will likely end up in the 3rd type. Spartacus will use the CMS api to fetch the content page for the given URL.

如果一个并不存在的url传递给Spartacus,会被当成content page处理,Spartacus会使用CMS API去读取该url对应的content page.

If the CMS cannot find a matching content page, it will respond with a 404 error. Spartacus will handle this 404 error, and redirect the user (under the hood) to the not found CMS page.

如果CMS返回404错误,Spartacus会显示CMS里model的not found CMS页面。

结果:显示not found页面


步骤如下:

navigation start:
app.module.ts:115 Jerry: NavigationStart(id: 1, url: ‘powertools-spa/en/USD/jerry’)

第二步:

Jerry: RoutesRecognized(id: 1, url: ‘powertools-spa/en/USD/jerry’, urlAfterRedirects: ‘powertools-spa/en/USD/jerry’, state: Route(url:’’, path:’’) { Route(url:‘jerry’, path:’**’) } )

第三步:

Jerry: GuardsCheckStart(id: 1, url: ‘powertools-spa/en/USD/jerry’, urlAfterRedirects: ‘powertools-spa/en/USD/jerry’, state: Route(url:’’, path:’’) { Route(url:‘jerry’, path:’**’) } )

第四步:

Jerry: ChildActivationStart(path: ‘’)

app.module.ts:115 Jerry: ActivationStart(path: ‘**’)

404错误:

id为jerry的content page不存在,但是not-found content page存在:


更多Jerry的原创文章,尽在:“汪子熙”:

汪子熙 CSDN认证博客专家 前端框架 Node.js SAP
JerryWang,2007年从电子科技大学计算机专业硕士毕业后加入SAP成都研究院工作至今。Jerry是SAP社区导师,SAP中国技术大使。2020年5月下旬,Jerry做了脑部肿瘤的开颅切除手术,对编程和人生又有了新的感悟。
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 博客之星2020 设计师:CY__ 返回首页