如果基本 url 包含端口号,则不会加载资产 - codeigniter 4 [英] Assets won't load if base url contains port number - codeigniter 4
问题描述
我正在运行 php spark serve
以在本地运行 codeigniter 4 应用程序.
I am running php spark serve
to run a codeigniter 4 app locally.
如果我的 $base_url
有一个端口号,我的所有资产都不会加载,但如果我删除端口号,它会加载
if my $base_url
have a port number, all my assets wont load, but it will if i remove the port number
这不会加载我的资产
public $baseURL = 'http://localhost:8080/folder_name';
这将加载我的资产
public $baseURL = 'http://localhost/folder_name';
关于为什么以及如何解决它的任何建议?
Any suggestion as to why and how to fix it?
推荐答案
希望我的回答不会迟到.
i hope my answer is not late.
由于 codeigniter 4 使用了 Spark 服务器,并且有很多更新.
since codeigniter 4 used spark server and there is many update.
- 只需将您的资产文件放入公共文件夹
- 例如在视图中加载您的资产
它将在文件夹 public/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 :)
这篇关于如果基本 url 包含端口号,则不会加载资产 - codeigniter 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!