Assets route in backend app

I run backend app in advanced template by this command: ./yii serve --docroot="backend/web/".
But when I open localhost - no styles are applied. The reason is that style tag in src has ‘/admin’ prefix before assets. If I delete that prefix styles work well. How can i fix that? Do I need to delete admin prefix somehow? Or may be generated css should be in admin folder. But how can it be achieved? Now I ended up with link tags hardcoded in main layout. Just copied path to css from browser inspector and put it in main layout without ‘/admin’. But styles are not precise (content gets udner navbar) and don’t work in /gii route. And that is just ridiculous workaround
By the way everything works fine if I serve frontend ./yii serve --docroot="frontend/web/".

Hi @PttRulez,
Welcome to Yii forums!

You have to explain how your app is structured and what that /admin is
We cannot pretend that we see your code somwhow

@evstevemd structure is standard which you get when just install yii2 advanced app with composer.
I have tried changin backend/config/main.php
'components' => [ 'baseUrl' => '/admin']
to just slash '/'. Now autogenerated home link in Navbar directs me to “site/index” (without host :slight_smile: )

It is only standard before monkeying with it

Thank you for your help @evstevemd :smiley: I finally solved it by completely removing baseUrl from config or just leaving it empty string

1 Like