简体   繁体   English

无法使用 Firebase 主机显示网站

[英]Unable to display website using Firebase Hosting

I am trying to host my dynamic Node.js website using Firebase Hosting but I am having difficulty based on my file structure.我正在尝试使用 Firebase 托管来托管我的动态 Node.js 网站,但根据我的文件结构,我遇到了困难。 Here is what is looks like:这是看起来的样子:

在此处输入图像描述

In my code, I am not using an index.html file but when I ran firebase init it automatically created one for me along with a 404.html file.在我的代码中,我没有使用 index.html 文件,但是当我运行firebase init时,它会自动为我创建一个 404.html 文件。 When I deploy my code, only index.html file seems to execute.当我部署我的代码时,似乎只有 index.html 文件在执行。 But when I try deploying after deleting the index.html file, I can see the 404.html file.但是当我在删除 index.html 文件后尝试部署时,我可以看到 404.html 文件。

在此处输入图像描述

This is the firebase.json file.这是 firebase.json 文件。 that I am using:我正在使用:

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

None of the files in the 'public/html' folder seem to be executing. “public/html”文件夹中的所有文件似乎都没有执行。 I tried changing the public field to public/html in the firebase.json file but then I can only see Cannot GET / when deployed.我尝试在 firebase.json 文件中将公共字段更改为 public/html,但随后我只能在部署时看到Cannot GET / How do I run the files in the 'public/html' folder when deploying along with the js files in the 'src/js' folder?与“src/js”文件夹中的 js 文件一起部署时,如何运行“public/html”文件夹中的文件?

I have an error.html file in my code which is located under 'public/html/main'.我的代码中有一个错误。html 文件位于“public/html/main”下。 If I want to use it besides the 404.html file, will I have to place in directly inside the public folder?如果我想在 404.html 文件之外使用它,我必须直接放在公用文件夹中吗?

Additionally, I also have a lot of backend files.此外,我还有很多后端文件。 In order to use those, do I need to use some other service offered by firebase or that can be accomplished by using Firebase Hosting itself?为了使用这些,我是否需要使用 firebase 提供的其他服务,或者可以通过使用 Firebase 托管本身来完成?

With Firebase Hosting, if you want to see web content when you load the "/" path, you will need a file called "index.html" in your public directory .使用 Firebase 托管,如果您想在加载“/”路径时查看 web 内容,则需要在公共目录中创建一个名为“index.html”的文件。 It will not look in subdirectories.它不会在子目录中查找。 By default, with the configuration you're showing, all the paths are served relative to public.默认情况下,使用您显示的配置,所有路径都相对于公共提供。

It's hard to tell what you're expecting to work differently.很难说出您期望以不同的方式工作。 If you want to refer to foo.html nested under html, then your path will need to be "/html/foo.html".如果你想引用嵌套在 html 下的 foo.html,那么你的路径需要是“/html/foo.html”。 If you want to change the hosting configuration to do something different, I suggest looking over the documentation .如果您想更改托管配置以做不同的事情,我建议您查看文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM