Non-static method Cake\Routing\RouteBuilder::scope() cannot be called statically
getting error Please let me know this error solution
Non-static method Cake\Routing\RouteBuilder::scope() cannot be called statically
getting error Please let me know this error solution
Make sure your routes.php file is built like
I have done as follows Please what is wrong in my code.
RouteBuilder::scope('/ContactDetails/add', function (RouteBuilder $routes) {
// Prior to 3.5.0 use `extensions()`
$routes->setExtensions(['json']);
$routes->resources('ContactDetails');
});
I got an error non-static method cake\Routing\RouteBuilder::scope() cannot be called statically.
Don’t call RouteBuilder::scope
which is a static method.
Wrap your routes (like the example file) so you always have an object
return static function (RouteBuilder $routes) {
$routes->setRouteClass(DashedRoute::class);
$routes->scope('/', function (RouteBuilder $builder) {
$builder->scope('/ContactDetails/add', function (RouteBuilder $routes) {
$routes->setExtensions(['json']);
$routes->resources('ContactDetails');
});
$builder->fallbacks();
});
};
I follow the same as you mentioned code but i got the error. remove following code
->add(new CsrfProtectionMiddleware([
'httponly' => true,
]))
I need the react app post data to my cakephp app so that i can store data but i got above error.
You need to add e.g.
X-CSRF-Token
HTTP header to your HTTP requests from react which contains the value from the _csrfToken
hidden input_csrfToken
value as part of the submitted dataBut that has nothing to do with your initial problem.