Laravel-Backpack / community-forum

A workspace to discuss improvement and feature ideas, before they're actually implemented.
28 stars 0 forks source link

[Bug] theme fonts links are absolute #764

Closed not82 closed 10 months ago

not82 commented 10 months ago

Bug report

What I did

Bought and used backpack6 with coreuiv2 In my local environment, my project isn't at the root of the domain, but in folder, for example : http://localhost/myproject

What I expected to happen

Properly load all assets

What happened

Some fonts aren't loaded, for example : http://localhost/storage/basset/source-sans-pro/SourceSans3-Regular.ttf.woff2 It's because the theme tries to load it from root, not by using APP_URL .env configuration It should load http://localhost/**myproject**/storage/basset/source-sans-pro/SourceSans3-Regular.ttf.woff2

What I've already tried to fix it

I see it's in the source-sans-pro.css that fonts are loaded using /storage , which can't work as expected. I can use many fix but it will change the way I manage my projects. It could be great if it can work out of the box.

Is it a bug in the latest version of Backpack?

Yes, in 6.3.2

Backpack, Laravel, PHP, DB version

PHP VERSION:

PHP 8.1.26 (cli) (built: Nov 22 2023 10:01:32) (ZTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend Engine v4.1.26, Copyright (c) Zend Technologies with Zend OPcache v8.1.26, Copyright (c), by Zend Technologies with Xdebug v3.2.2, Copyright (c) 2002-2023, by Derick Rethans

LARAVEL VERSION:

10.33.0.0

BACKPACK PACKAGE VERSIONS:

backpack/basset: 1.2.2 backpack/crud: 6.3.2 backpack/generators: v4.0.2 backpack/permissionmanager: 7.1.1 backpack/pro: 2.0.18 backpack/theme-coreuiv2: 1.2.2

promatik commented 10 months ago

Hi @not82! What is your APP_URL value on .env file?

I guess you may solve your issue if you set APP_URL=http//localhost/myproject.


You can also force Basset to use relative paths with the follow env variable;

BASSET_RELATIVE_PATHS=true

Or by changing the config:

app/config/backpack/basset.php

relative_paths => true`

Probably this is a better (safer?) solution than changing your APP_URL. Let me know 🙌

not82 commented 10 months ago

Hi @promatik ,

My APP_URL is well defined : APP_URL=http://localhost/myproject

Basset is configured by default so BASSET_RELATIVE_PATHS is true by default ( no .env definition ) Still have the error. Doesn't append with theme-tabler ( but it has no fonts as it seams )

Is there a cache to force or something ?

not82 commented 10 months ago

Got exactly the same issue with a fresh install ( the above is on a migration from 4.1 )

not82 commented 10 months ago

Is it the same issue or not, when I put in config/backpack/ui.php :

'styles' => [
'styles/example.css'
]

it doesn't work : when I execute the page, example.css isn't called to be loaded.

While in 'scripts' it works : I have the load call to the script ( if the file exists or not ) While in theme-tabler.php , the css is tried to load ( if it exists or not )

Tested in my migrated project and on a fresh project. There should be a basset issue there too.

pxpm commented 10 months ago

Hey @not82

Those files may be overwritten by the theme, and that take precedence over UI.

Have a look at my answer here: https://github.com/Laravel-Backpack/community-forum/discussions/744#discussioncomment-7618913

Let me know if that helps.

Cheers

not82 commented 10 months ago

Hi @pxpm, ok for this point, but it's not very natural : changing theme should not break the actual behavior defined in an higher place ( ui.php )
Thanks.

pxpm commented 10 months ago

Hi @pxpm, ok for this point, but it's not very natural : changing theme should not break the actual behavior defined in an higher place ( ui.php ) Thanks.

Sorry @not82 I've missed this comment.

Actually it should be read the other way around. ui is the base layer, themes goes on top of it, and you can build you custom theme on top of other themes etc.

Let me know if this helps to clarify that: https://backpackforlaravel.com/docs/6.x/base-themes#theme-view-fallbacks-1

If you have any suggestions on how to improve the docs to make it more clear, please let us know 🙏

Cheers

pxpm commented 10 months ago

going to close, please reopen if your issue still not solved.

thanks 🙏