Assets won't load if base url contains port number - codeigniter 4

删除回忆录丶 提交于 2021-02-11 13:54:26

问题


I am running php spark serve to run a codeigniter 4 app locally.

if my $base_url have a port number, all my assets wont load, but it will if i remove the port number

This wont load my assets

public $baseURL = 'http://localhost:8080/folder_name';

This will load my assets

public $baseURL = 'http://localhost/folder_name';

Any suggestion as to why and how to fix it?


回答1:


i hope my answer is not late.

since codeigniter 4 used spark server and there is many update.

  1. Just put your asset file to public folder

  1. load your asset at view for example

<link rel="stylesheet" href="<?=base_url('vendor/login-register/css/style.css')?>">

it will load your asset at folder public/vendor/login-register/css/style.css

let me know if you have any question or another issues :)



来源:https://stackoverflow.com/questions/61737998/assets-wont-load-if-base-url-contains-port-number-codeigniter-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!