siadhr-programmer's avatar

Vite Asset relative and absolute URL issue

when deploying laravel web app to the server, assets path use absolute path instead of relative path, this affecting performance since every time visiting page resources are called using network now rendered resources href and src attributes looks like href="https://domanin.com/build/asset-name.js" i need it to be rendered with relative url like href="/build/asset-name.js"

thanks in advance

0 likes
4 replies
edgarkosul's avatar

šŸ’” A quick tip for anyone encountering issues with loading assets in Laravel:

If the ASSET_URL variable is not set, Laravel will automatically default to the app's URL. This might cause problems with loading static files correctly.

šŸ”§ Solution: Set ASSET_URL in the .env file:

ASSET_URL=/

Everything should work smoothly now! šŸ˜‰

Please or to participate in this conversation.