Grocery Crud Enterprise - Going back - browser last page error

I have two pages using grocery crud in both pages. When I go to the seccond page and then if I click in the browser “back to last page” button, I receive the error:

Something went wrong!

We can’t process the response of the server. This is all we know about it:

Summary: Not well JSON formatted response

Error: Not well JSON formatted response

How should I fix that? Thank you very much.

Hello. I have tested without my dashboard layout and it has worked better. Maby is something on the layout. Anyway, I removed all js from layout and it still crashes.

I’m using the grocery crud enterprise edition with CodeIgniter 4 last version + Admin Lite layout last version.

Is there a way to debug and understand how the json is returning?

If i click F5 or refresh page it works… the problem only happens when I move back from one page to another using the browser back one page button.
image

This bug is also happening when I use the redirect function:

$crud->unsetDelete();
$crud->callbackAfterUpdate(function ($stateParameters) {
$redirectResponse = new \GroceryCrud\Core\Redirect\RedirectResponse();
return $redirectResponse->setUrl(site_url().‘forms/form_inputs/’.$stateParameters->primaryKeyValue.’#/!’);
});

Sometimes it works, sometimes the error print sent above in first post happens.

Checking access log, aparently there is a missing GET

::1 - - [03/Jan/2022:18:58:12 -0300] “POST /forms/form_inputs/1 HTTP/1.1” 303 -
::1 - - [03/Jan/2022:18:58:13 -0300] “GET /forms/form_inputs/1 HTTP/1.1” 200 13336

above, we have the two requests using the back to last page browser button. error is shown on screen.
bellow, we have the three requests related to a refresh on the same page. success on crud render.

::1 - - [03/Jan/2022:18:58:31 -0300] “GET /forms/form_inputs/1 HTTP/1.1” 200 13336
::1 - - [03/Jan/2022:18:58:31 -0300] “GET /forms/form_inputs/1?action=initial HTTP/1.1” 200 5556
::1 - - [03/Jan/2022:18:58:31 -0300] “POST /forms/form_inputs/1 HTTP/1.1” 200 1247

I have reproduced the usage without codeigniter and without admin lite layout and no error happened, same logs:

::1 - - [03/Jan/2022:19:10:14 -0300] “GET /groceria/examples/example.php HTTP/1.1” 200 1841
::1 - - [03/Jan/2022:19:10:14 -0300] “GET /groceria/examples/example.php?action=initial HTTP/1.1” 200 6371
::1 - - [03/Jan/2022:19:10:14 -0300] “POST /groceria/examples/example.php HTTP/1.1” 200 455
::1 - - [03/Jan/2022:19:10:22 -0300] “GET /groceria/examples/example2.php HTTP/1.1” 200 1842
::1 - - [03/Jan/2022:19:10:22 -0300] “POST /groceria/examples/example2.php HTTP/1.1” 200 455

I have found the problem!

$crud->setCsrfTokenName(csrf_token());
$crud->setCsrfTokenValue(csrf_hash());

When these are active, it won’t work. Is this a bug with a fix?

I have deactivated csrf and then everything is working now.

Double checking here, actualy I had to change this on filters.php
comment line with csrf…
image