adobe / aem-spa-page-model-manager

Interface between Adobe Experience Manager and Single Page Application framework.
Apache License 2.0
34 stars 24 forks source link

[bug] 400 bad request on ".model.json" #18

Closed I2obiN closed 3 years ago

I2obiN commented 3 years ago

Describe the bug The ModelManager initializes correct on my page with "us.model.json". For some reason the aem-spa-page-model-manager then makes a request to ".model.json" a resource that can't possibly exist and gets a 400 response breaking the react application.

Package version latest

To Reproduce I cannot reproduce this, AEM suddenly started behaving like this

Expected behavior Only validated values should be passed

Additional context Page was working then suddenly was not

pfauchere commented 3 years ago

@I2obiN Could you please provide steps so that we can systematically reproduce the problem?

claudiab commented 3 years ago

Hi, I have seen this weird error come up.

Package version "@adobe/cq-spa-page-model-manager": "1.1.3",

To Reproduce First spotted issue after deploying app into testing environment. Steps to see this problem locally:

  1. Generate sample project
    mvn -B archetype:generate \ -D archetypeGroupId=com.adobe.granite.archetypes \ -D archetypeArtifactId=aem-project-archetype \ -D archetypeVersion=23 \ -D aemVersion=6.5.4 \ -D appTitle="My Site" \ -D appId="mysite" \ -D groupId="com.mysite" \ -D frontendModule=angular \ -D includeExamples=y

  2. Go to app-routing.module.ts:

  3. Update Routes priority { path: '', redirectTo: enviroment.APP_ROOT_PATH, pathMatch: 'full', }, { matcher: AemPageMatcher, component: PageComponent, resolve: { path: AemPageDataResolver, }

  4. Add cq:pagemodel_route_filters to customheaders.html and index.html < meta property="cq:pagemodel_route_filters" content="index,^(.)(?:index)(.)" >

  5. Run mvn clean install -PautoInstallPackage from root

  6. Run npm start from ui.frontend

  7. Go to browser and access app from http://localhost:4200/index.html

  8. App routes to http://localhost:4200/content/mysite/us/en/home.html with error from index.model.json

  9. 400 errors from index.model.json break angular app

Errors:

aem-double-model-error-2 aem-double-model-error

Expected behavior App should automatically route from http://localhost:4200/index.html to http://localhost:4200/content/us/en/mysite.html and not show errors for index.model.json

This error did not come up with old package: "@adobe/cq-spa-page-model-manager": "1.1.3",

grubyak commented 3 years ago

thank you @I2obiN and @claudiab for detailed reproduction steps, we are going to work on that now.

grubyak commented 3 years ago

archetype generator <=24 will still produce a buggy project, it's because:

we suggest following manual steps to fix the problem:

mentioned steps won't be needed for project generated with archetype 25+

voghan commented 3 years ago

Is the expected behavior to always change the location.href to appRoot for the application to load the SPA application? Our client does not want to see that after their website domain.