superstatic always loads configs from existing `firebase.json` file on project root

未关闭
#503 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 5 天内回复

@jabrailkhalil 已经在做这个了。

开始于 2026年10月3日。

  • #536 来自 @swseverance —— 已关闭,未合并
  • #593 来自 @jabrailkhalil —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
firebase, javascript
领域
backend

调研方向

从 index.js 复现开始,在项目根目录存在 firebase.json 时,使用提供的配置跟踪 superstatic.server 的启动过程。比较有无 firebase.json 时产生的标头,然后添加覆盖测试,证明显式配置不会被意外覆盖;当复现情况下仅由 firebase.json 提供的标头不存在时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

Would it be possible to prevent superstatic from automatically loading hosting configs from firebase.json?

When I run a code like

index.js
const superstatic = require('superstatic');

const options = {
    host: "127.0.0.1",
    port: 5004,
}

const config = {
    "public": "public",
    "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
    ],
    "site": "demo-project"
}

const server = superstatic.server({
    debug: false,
    port: options.port,
    hostname: options.host,
    config: config,
    compression: true,
    cwd: process.cwd() || undefined,
}).listen(() => {
    const siteName = config.target || config.site;
    const label = siteName ? "hosting[" + siteName + "]" : "hosting";
    if (config.public && config.public !== ".") {
        console.log("BULLET", label, "Serving hosting files from: " + config.public);
    }
    console.log("SUCCESS", label, "Local server: " + "http://" + options.host + ":" + options.port);
});

server.on("error", (err) => {
    console.log("DEBUG", `Error from superstatic server: ${err.stack || ""}`);
    throw new Error(`An error occurred while starting the hosting development server:\n\n${err.message}`);
});

with a firebase.json file on project directory

firebase.json
{
  "hosting": {
    "public": "public",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ],
    "headers": [
      {
        "source": "/",
        "headers": [
          {
            "key": "header-in-firebase-json",
            "value": "ehhhhhhhhhhhhh?????"
          }
        ]
      }
    ]
  }
}

Running curl -I http://127.0.0.1:5004 will output a header-in-firebase-json(only specified in firebase.json) in the response headers even though I did not specify is in the config(index.js)

$ curl -I http://127.0.0.1:5004
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 234
ETag: a3b67dafcd419de50643d682c2fb2e15
Last-Modified: Thu, 22 Jan 2026 12:59:07 GMT
Vary: Accept-Encoding
header-in-firebase-json: ehhhhhhhhhhhhh?????
Date: Thu, 22 Jan 2026 13:07:54 GMT
Connection: keep-alive
Keep-Alive: timeout=5

mcve - https://github.com/aalej/superstatic-503
related to - https://github.com/firebase/firebase-tools/issues/9773

主要语言
TypeScript
星标
1.1k
派生
90
平均合并
3 天 19 小时
30 天内合并 PR
13

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/superstatic 的其他 Issue

查看 firebase/superstatic 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。