我在Firebase Hosting中托管了一个网站,当我仅从当前public
文件夹中加载内容时,它可以正常工作。但是我无法从/img/logo.png
这样的子目录加载任何内容。
我已经在这里和互联网上进行搜索,但找不到有效的解决方案。我尝试过的一些类似问题:
Images not showing up in hosted site
How to include subdirectories in firebase hosting
我的收录类似于<script src="js/index.js"></script>
我的firebase.json
:
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"headers": [ {
"source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
"headers" : [ {
"key" : "Access-Control-Allow-Origin",
"value" : "*"
} ]
}, {
"source" : "**/*.@(jpg|jpeg|gif|png)",
"headers" : [ {
"key" : "Cache-Control",
"value" : "max-age=7200"
} ]
}, {
"source" : "404.html",
"headers" : [ {
"key" : "Cache-Control",
"value" : "max-age=300"
} ]
} ]
}
}
答案 0 :(得分:0)
通过在Windows上的Ubuntu的Bash中运行firebase deploy
来解决此问题。
以前,我是在普通Windows 10上使用firebase cli。