leafsphp / mvc-core

Core functions and configurations for Leaf MVC, Leaf API and Skeleton
https://leafphp.dev/modules/mvc-core/
3 stars 4 forks source link

Leaf MVC: `assets()` function behaves differently and breaks in production #14

Open reinhart1010 opened 6 months ago

reinhart1010 commented 6 months ago

Describe the bug At least in Leaf 3, the assets() function (used to get the absolute URL path for asset files) behaves differently between leaf serve and production (LiteSpeed Enterprise).

To Reproduce The Leaf MVC starter template (obtainable from leaf create project-name --mvc --v3) already contains a CSS <link rel="stylesheet"> declaration referring to a dynamically-generated path using the assets('css/styles.css') function. When trying to run the app using leaf serve, the web app styles loaded correctly, rendering the CSS tag as:

<link rel="stylesheet" href="/assets/css/styles.css">

However, when trying to deploy the app to production (using LiteSpeed Enterprise Server, and possibly reproducible in OpenLiteSpeed and Apache) when the website's root points to the public/ folder, the web server renders the style declaration as:

<link rel="stylesheet" href="/public/assets/css/styles.css">

Breaking the overall external CSS and JS paths.

This is reproducible in:

JensRoland commented 6 months ago

I am getting a somewhat similar error... I created a new Leaf 3 MVC app, and when I run leaf serve the assets can only be referenced on /public/assets/... due to the combination of .htaccess and index.php files.

The following works as expected:

php -S localhost:8000 -t public/
mychidarko commented 1 month ago

Taking a look at this

phederal commented 3 weeks ago

@mychidarko Bug on this code line image

It should be true here, not /

phederal commented 3 weeks ago

Taking a look at this

@mychidarko Can you fix this in the composer package? I've attached a screenshot of the fix above.

mychidarko commented 3 weeks ago

I'm currently testing a few updates along with the fix. I'll have a new version out soon @phederal

mychidarko commented 1 day ago

I forgot to check back here @JensRoland @reinhart1010 @phederal. Has this issue been fixed?