I Installed Drupal 9.1.0 on a VPS running on Ubuntu 20.4 and using Nginx 1.18.0, with Composer 2.0.8.
I installed two modules (Token and Devel) and a theme (Barrio) using Composer. I can enable the modules without problem, but when I try to install Barrio and set it as default theme, I get an access denied error.
I tried to enable other themes, but I always get the same error.
I cleared the cache and installed the theme with Drush. Still, setting the theme as default one causes an error. In this case, the error in the log is the following one.
Path: /admin/appearance/default?theme=THEME_NAME&token=TOKEN. Drupal\Core\Http\Exception\CacheableAccessDeniedHttpException: 'csrf_token' URL query argument is missing. in Drupal\Core\Routing\AccessAwareRouter->checkAccess() (line 117 of /PATHTOSITE/core/lib/Drupal/Core/Routing/AccessAwareRouter.php).
...:: UPDATE ::...
I used to start debugging to check where exactly the problem happens and realized that in line 57 of /Drupal/Core/Access/CsrfAccessCheck.php where code says :
$request->query->get('token', '')
there results become '' , which means $request->query->token is empty. debugging backward I looked at many files including :
Drupal/Core/Access/AccessArgumentsResolverFactory.php where it produces $request for csrfCheck
Drupal/Component/Utility/ArgumentsResolver.php which is used in above file
and finally I got to the place where problem is started:
Drupal/Core/Routing/RouteMatch::createFromRequest
this method can not recognize the token in url and cause all other problems, but I still don't know what cause this method failure
could it be my Nginx configurations?
Nginx config is:
location / { try_files $uri $uri/ /index.php?query_string; }
One more thing , when I use dsm on request, token can be find in $request->requestUri (is shown as /admin/appearance/install?theme=stark&token=qI5_B99oNr4TWdNfu5aTdd01NezSpPKOZje8HCVOMEs), But $rquest->query["query_string"] is ""