beyondcode / herd-community

85 stars 1 forks source link

[Bug]: Site Works As Expected in Valet, Not in Herd #636

Closed kylekanderson closed 6 months ago

kylekanderson commented 6 months ago

Platform

macOS

Operating system version

macOS Sonoma v14.4.1

System architecture

ARM64 (M1, M2, etc)

Herd Version

1.5.0 (Build: 23)

PHP Version

PHP 8.2.16

Bug description

I have a site that works as-expected in Laravel Valet. However, when serving the site via Herd, I'm seeing the following issues:

  1. I am unable to login to the site. Either via a jetstream login page, via Filament, or via Laravel Nova. Any attempt to login to the site results in a redirect back to the login page.
  2. I have the laravel-debugbar extension installed in the project. When enabling the debugbar, it is showing up entirely unstyled at the bottom of my page. See screenshot example below: 2024-04-11 at 14 51 00

I use Herd to serve several other sites without any incident, so it's likely something specific to this site. However, if I quit Herd, then install Laravel Valet and serve the site via Valet (using the same PHP version), it all works as expected.

Steps to reproduce

No response

Relevant log output

No response

mpociot commented 6 months ago

Does this site have a custom folder structure? The fact that the debugbar is unstyled must be related to not being able to resolve CSS requests. Do you see something related to this in the network inspector in your browsers devtools?

kylekanderson commented 6 months ago

Hi @mpociot-

Thanks for your help here. No, the site is using the typical Laravel folder structure. And I thought the same about the debugbar assets, but I can see they're being loaded as-expected on the network tab: 2024-04-12 at 09 09 13

In case it's useful, I'm using the following in my .env:

CACHE_DRIVER=file QUEUE_CONNECTION=sync SESSION_DRIVER=database

kylekanderson commented 6 months ago

So, a little more to report here...

I've compared the debugbar css & js being served from the "faulty" site against debugbar css & js from another site that works as expected with Herd; and it appears that chrome is not recognizing the css & js from the "faulty" site as valid css or js. Seems like there may be something happening with the encoding of the files.

For example, when I open the "faulty" css in chrome: 2024-04-12 at 09 34 59

Whereas the working css appears as: 2024-04-12 at 09 35 11

I'm wondering if maybe there might be something with Herd that's causing the "faulty" site to not properly encode data?

mpociot commented 6 months ago

I'm wondering if this has something to do with PHP's output buffer size. Can you see if adding output_buffering=4096 to your php.ini and then restart the services fixes this?

It should already be present in your php.ini, but it depends a bit on when you installed Laravel Herd as this was added in a later release.

kylekanderson commented 6 months ago

@mpociot - that solved it! Incredible, thank you so much! I saw you mention this on another ticket and tried adding it yesterday, but I must have just forgotten to restart the services afterwards.

Thanks again for the help!