Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.8.0]: It appears subfolder CP URLs have broke, causing 404 #14559

Closed
zadro opened this issue Mar 8, 2024 · 10 comments
Closed

[4.8.0]: It appears subfolder CP URLs have broke, causing 404 #14559

zadro opened this issue Mar 8, 2024 · 10 comments

Comments

@zadro
Copy link

zadro commented Mar 8, 2024

What happened?

Description

Subfolder projects no longer allow login after upgrading to both 4.8.0 and 4.8.1 in the Utilities menu.

Subfolder name gets doubled on the POST request to:

/folder/folder/index.php

This then produces a 404, and the login returns "undefined" on any login attempt.

Steps to reproduce

  1. Upgrade to the latest Craft CMS version
  2. Try to login

Expected behavior

Successful login.

Actual behavior

404 to any login/forgot password path, such as: index.php?p=admin%2Factions%2Fusers%2Flogin&v=1709929415918

Craft CMS version

4.8.0

PHP version

8.1

Operating system and version

Debian 12

Database type and version

MySql

Image driver and version

No response

Installed plugins and versions

No plugins. Staged subfolder site.

@brandonkelly
Copy link
Member

This is most likely happening because you are manually setting the @web alias, and setting it to the wrong base URL (omitting the subpath).

@web always needs to be set to the exact base URL that you are accessing Craft from, including the subpath if index.php dosen’t live at the root of the hostname.

(That’s what will happen by default if you don’t set it manually.)

@zadro
Copy link
Author

zadro commented Mar 11, 2024

This is how I've added the aliases prior to v4.8 without any issues:

    ->aliases([
        '@webroot' => dirname(__DIR__) . '/web',
        // Avoids potential cache poisoning
        // Make sure .env file is set
        '@web' => App::env('PRIMARY_SITE_URL')        
    ])

With .env having: PRIMARY_SITE_URL=https://staged.example.com/folder

I have tried adding a trailing slash on the folder, same result.

Did I miss something? Thank you.

@brandonkelly
Copy link
Member

What is the exact URL of your index.php file, and what URL are you using to access the control panel?

@zadro
Copy link
Author

zadro commented Mar 11, 2024

The URL of index.php is at https://staged.example.com/folder/web/index.php

CP access is https://staged.example.com/folder/admin/

EDIT: Also, to reiterate, this config worked fine before either 4.8.0 or 4.8.1, and downgrading to 4.7.1 makes the sub-folder staged site functional again for CP access.

@brandonkelly
Copy link
Member

brandonkelly commented Mar 11, 2024

The URL of index.php is at https://staged.example.com/folder/web/index.php

So @web should be set to https://staged.example.com/folder/web, then, not https://staged.example.com/folder/.

I understand it was working prior to 4.8.1 for you, but it is still a misconfiguration issue. The change is 4.8.1 is non-breaking if @web is set correctly.

@zadro
Copy link
Author

zadro commented Mar 12, 2024

Hmm, but then a standard, non-subfolder, site isn't supposed to include /web in the PRIMARY_SITE_URL environment variable per docs? Ok, I'll update .env to include web and let you know if there are still issues. It was odd this process started working differently in 4.8.1, and I thought to open an issue.

EDIT
After updating, as you instructed, it's still not working and worse...breaks all CSS/JS for CP.

From my original issue, CP tries to access: /folder/folder/index.php per dev tools. It's doubling the sub-folder, and I'm not calling it twice in any aliases.

The site should be live at https://staged.example.com/folder/ NOT https://staged.example.com/folder/web/
The index.php file is at: /home/username/craft/web/index.php
Nginx points to /web for it's root path.

What exactly should @webroot and @web be set to for a working sub-folder installation of Craft 4.8.1?

We stage all our client sites in a subfolder, and they're all non-functional with the 4.8.1 update (they worked fine previously).

brandonkelly added a commit that referenced this issue Mar 12, 2024
@brandonkelly
Copy link
Member

Just tested that setup locally and was able to reproduce, and got it fixed for the next release.

I’ll get that out ASAP, but you can get the fix immediately by changing your craftcms/cms requirement in composer.json to "dev-develop as 4.8.1", and running composer update.

Sorry for the hassle!

@zadro
Copy link
Author

zadro commented Mar 12, 2024

Thanks, Brandon! Much appreciated.

@brandonkelly
Copy link
Member

Thanks for bearing with me! 4.8.2 (and 5.0.0-beta.7) are out now with that fix.

@zadro
Copy link
Author

zadro commented Mar 13, 2024

Updated and working beautifully! Thanks for making this a priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants