Requested content not found

Hello

I have three different pages, on iOS, when going back with swipe gesture, back on the first page this first page (/home/) does not appear but the message:

Sorry, Requested content not found.

Also, if I check the route with

$$(document).on('page:init', '.page', function (e) {
console.log(app.views.main.router.currentRoute);
});

there is no route showing in the console for the first page/homepage.

What could be the problem?

Thank you!

Leo

More likely you have wrong your routes configuration

Don’t know what could be wrong here…

var routes = [
  // Index page
  {
    path: '/home/',
    url: './index.php',
    name: 'home',
  },
  // User list
  {
    path: '/users/',
    url: './users.php',
    name: 'users',
  },
  // User Details
  {
    path: '/userdetails/',
    url: './user_details.php',
    name: 'userdetails',
       },


    {
      path: '/homework/',
      url: './homework_overview.php',
      name: 'homework',
      options: {
         animate: false,
      },
},

  // Default route (404 page). MUST BE THE LAST
  {
    path: '(.*)',
    url: './pages/404.html',
  },
];

Problem seems to be this:

When I first access to the homepage and navigate to other pages and then back to the homepage, the error appears.

When I then continue navigating to pages and then back to the homepage again, no error.

It seams, that the page is not registered as route when first accessing it…

Also:

$$(document).on('page:init', '.page[data-name="home"]', function (e) {

alert('Test');

});

does not work on first visit of the page under https://mydomain.com/

It works instead if I go to https://mydomain.com/#!/home/

Why?

Can someone help me…? Still stuck on this problem and couldn’t find the solution yet…

Thank you!!

There must be a route with path: '/' if you want it to work, I don’t see in your example above that you have such route

Ok, changed that back. I used ‘home’ instead of ‘/’ because my home-page is not loaded when reloading in browser:

browserHistory: true,

→ click to a link to a page “users”
→ then go back to the homepage (click on link)
→ Reload site trough browser reload button
→ I land on the “user” page and not on home.

With ‘home’ instead of ‘/’ this problem is solved…

Whats the mistake here?

Would be good to see live example with the issue. Hard to say like that then

Two points:

  1. Back link from users to home should be a link with back class to properly handle history, in your case you do navigation forward to home page
  2. You have wrong browserHistory config, you app is not on the root of the server, so you need to correctly specify browserHistoryRoot parameter. Right now your home page route detected as the following one:

That is why you see Not Found page when you go back to it

On your home page:

app.views.main.router.currentRoute.url

still shows /homework/f7/ but it must be /, which means you set wrong browserHistoryRoot, it shouldn’t include the domain itself, only path, e.g. try /homework/f7/ or /homework/f7

Problem is only on iOS:

Because with browserHistory=true there is a strange double-loading bug when swiping back, I did this:

if (Framework7.device.ios) {

var app = new Framework7({
  id: 'io.framework7.testapp',
  el: '#app',
  theme: theme,
  cache: false,
  autoDarkTheme: true,
  view: {
name: "main",
xhrCache: false,
browserHistory: false,
browserHistoryRoot: "/homework/f7/",
  },
...

Because browserHistory is false, browserHistoryRoot is not followed.

Any workaround or other solution?

On your main view element you must specify what is its default URL, should be done via data-url="/" attribute on View element.

Yes, this works! Thank you!!