Open dgsiegel opened 9 months ago
I couldn't reproduce the issue on Chrome and Firefox. My steps:
/panel/login
and try to login/panel
or /panel/login
or /panel/site
manuallyDo you have any plugins, custom js or hooks?
Do you have any plugins, custom js or hooks?
Thanks for the hints! I should have tested this issue first with the Starterkit, as it doesn't happen there. The culprit is of course the relative URL workaround I've described here: https://github.com/getkirby/kirby/issues/6078#issuecomment-1868343757
Setting the index.php like I've described there will indeed bring up the issue. Is there a way to keep this workaround?
@afbora it looks like the frontend JS doesn't behave well with relative URLs in the Location
parameter in the header. If you would change this line https://github.com/getkirby/kirby/blob/main/src/Panel/Home.php#L48 to return App::instance()->url('base', true);
, ie. always return a full URL, the issue goes away.
@afbora on further investigation the issue looks like this:
index.php
like this:<?php
require 'kirby/bootstrap.php';
$kirby = new Kirby([
'urls' => [
'index' => '/',
],
]);
echo $kirby->render();
alternative
function will be called (https://github.com/getkirby/kirby/blob/main/src/Panel/Home.php#L42)/
instead of a full URL with hostLocation
parameter in the redirect will be set to /panel
continuously and we got an infinite loop, which a browser will stop at some point with NetworkError when attempting to fetch resource
or net::ERR_TOO_MANY_REDIRECTS
url
function (https://github.com/getkirby/kirby/blob/main/src/Panel/Panel.php#L566) which "should" Create an absolute Panel URL independent of the Panel slug config
.$baseUri = new Uri($kirby->url());
(https://github.com/getkirby/kirby/blob/main/src/Panel/Panel.php#L574) with this setup$baseUri = new Uri($kirby->url('base', true));
as that would make sure that you always return an absolute URL with host, even if no host was defined before.@afbora is there anything else you need to replicate this?
Sorry @dgsiegel I can't reproduce the issue. Is your setup in subfolder?
Sorry @dgsiegel I can't reproduce the issue. Is your setup in subfolder?
@afbora, nope just a normal installation.
Here is a diff you can apply onto a plainkit setup with the following changes:
site/blueprints/users/nologin.yml
containing the role which should have no access to the panelindex.php
(see above) in order to have relative URLsI am running the setup via php -S localhost:8080 kirby/router.php
, but that shouldn't make a difference
diff -Nur '--exclude=accounts' plainkit-main/index.php plainkit-bug/index.php
--- plainkit-main/index.php 2024-03-06 12:41:59.000000000 +0100
+++ plainkit-bug/index.php 2024-03-16 13:27:27.025673095 +0100
@@ -2,4 +2,10 @@
require 'kirby/bootstrap.php';
-echo (new Kirby)->render();
+$kirby = new Kirby([
+ 'urls' => [
+ 'index' => '/',
+ ],
+]);
+
+echo $kirby->render();
diff -Nur '--exclude=accounts' plainkit-main/site/blueprints/users/nologin.yml plainkit-bug/site/blueprints/users/nologin.yml
--- plainkit-main/site/blueprints/users/nologin.yml 1970-01-01 01:00:00.000000000 +0100
+++ plainkit-bug/site/blueprints/users/nologin.yml 2024-03-16 13:26:39.537982941 +0100
@@ -0,0 +1,6 @@
+title: Nologin
+description: The nologin user can't login
+
+permissions:
+ access:
+ panel: false
After installing the plainkit, create a new user with the nologin
role and try to log in in a fresh browser.
I am receiving the error screen "You are not allowed to access the panel" - which is different from the console errors you are describing. But indeed not the redirect to the site.
@distantnative maybe there's a difference in how we set up our projects. I've created a zip containing all my changes:
After downloading,
php -S localhost:8080 kirby/router.php
inside the directoryhttp://localhost:8080/panel/login
nologin@nologin.com
and nologin1
Sorry for late. I've tested your setup (with subfolder 'index' => '/test/kirby/6179/'
) and works for me (redirected to the homepage) as expected.
Sorry for late. I've tested your setup (with subfolder
'index' => '/test/kirby/6179/'
) and works for me (redirected to the homepage) as expected.
Yeah, this won't work with a subfolder as you never will get an invalid string as with /
. You would need to run this directly on localhost or whatever local development domain you use.
This issue has been marked as stale because it requires further input but has not seen activity in the past months. This is for us to prioritize issues that are still relevant and actionable. It will be closed if no further activity occurs within the next 15 days. If this issue is still relevant to you, please help us in gathering the necessary input.
This issue has been marked as stale because it requires further input but has not seen activity in the past months. This is for us to prioritize issues that are still relevant and actionable. It will be closed if no further activity occurs within the next 15 days. If this issue is still relevant to you, please help us in gathering the necessary input.
@afbora @distantnative what further input do you need?
@dgsiegel I can now reproduce the issue.
However, your suggested fix doesn't seem to work for me. I still get the network error using
$baseUri = $kirby->url('base', true);
Did it resolve the issue on your end?
Did it resolve the issue on your end?
Yes, it did fix the issue for me. But I was using
return App::instance()->url('base', true);
in https://github.com/getkirby/kirby/blob/main/src/Panel/Home.php#L48
Don't know if that makes any difference? Also, you need to clear all cookies and storage in your browser, otherwise you'll always get the network error.
Description
I've set up a user role like this:
Then I've created a new user with this role and set a password. When trying to log in with this user, I get a dialog saying
NetworkError when attempting to fetch resource.
. On reload the page will break until I delete the session cookie with the browser errorThe page isn’t redirecting properly
.The Firefox browser console shows this:
Chrome shows this:
Expected behavior
I'd expect a permission denied error or no error message.
Your setup
Kirby Version
4.0.3