随着Divshot最近关闭,我已将许多应用程序切换到Firebase托管.其中一些应用程序连接到外部API,因此我需要一种方法来存储Firebase托管上的私有环境变量(例如,S3访问的密钥) - 任何人都有任何想法?这篇文章是https://www.firebase.com/blog/2015-10-29-managing-development-environments.html - 但这仅适用于非私有环境变量.
谢谢!
Cache-Control我的firebase.json文件中的标头设置似乎不起作用.我已将max-age所有文件的值设置为31536000(1年).我的firebase.json文件是 -
{
"hosting": {
"public": "public"
},
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"headers": [{
"source": "**",
"headers": [{
"key": "Cache-Control",
"value": "max-age=31536000"
}]
}]
}
Run Code Online (Sandbox Code Playgroud)
该文件似乎遵守firebase文档.
但是max-age,对于所有文件,该值仍设置为浏览器默认值3600(1小时).
我以前曾经多次部署过.出于某种原因,今天我收到这个错误,我似乎无法解决.我尝试用2或4个空格更改标签.我尝试了不同的格式,没有任何作用.
这就是它所说的:
Error: There was an error loading firebase.json
Trailing comma in object at 29:9
}
^
Run Code Online (Sandbox Code Playgroud)
这是我的firebase.json
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "public"
}
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
PS:如果您还有其他需求,请询问.
是否可以将firebase函数中的静态资源部署到firebase托管?
使用案例:包含静态html文件的博客.博客内容和元信息将存储在数据库中(内容为降价).在发布或更新时,将触发firebase函数,该函数解析markdown并为博客帖子生成静态html文件,并将其部署到firebase托管.部署后,该函数会将实时URL存储在数据库中.
这个工作流程是否可行?在当前的文档中,我找不到任何有关从函数部署的内容.
作为一种解决方法,我可以设想使用travis-ci进行设置.该函数触发travis上的重建,travis构建静态资产并将它们部署到firebase托管,但这似乎是一个巨大的开销.
我也可以从数据库中提取markdown内容并在客户端上构建,但我真的很想尝试静态文件方法以获得初始加载时间的原因.
我知道这首先错过了使用Cloud Functions的意义,但是在我的特定情况下,我正在使用Cloud Functions,因为这是将Next.js与Firebase Hosting桥接的唯一方法。我不需要使其具有成本效益,等等。
话虽如此,Cloud Functions的冷启动时间简直难以忍受,而且还不能投入生产,对于我的样板,平均大约需要10到15秒。
我当然已经看过Google的这段视频(https://www.youtube.com/watch?v=IOXrwFqR6kY),其中谈到了如何减少冷启动时间。简而言之:1)修剪依赖关系; 2)依赖关系版本在Google网络缓存中的尝试和错误; 3)延迟加载。
但是,嘿,1)我可以裁剪的依赖项太多了。2)真是无用的建议!我怎么知道哪个版本的缓存更多?3)只有太多依赖项可以延迟加载。
另一种方法是一起避免冷启动。从本质上讲,我可以使(一个或唯一一个)云功能保持温暖是什么好方法?
每当我在我的mac上运行firebase服务器时,我收到404错误...这在以前从未发生过,我只是在开始发生前5分钟使用本地开发服务器.我删除了firebase.json文件并重新初始化它,重新安装了firebase工具,但每次都失败了.以下是在调试模式下运行命令的结果.
firebase serve --debug
[2018-09-11T16:12:25.873Z] ----------------------------------------------------------------------
[2018-09-11T16:12:25.876Z] Command: /usr/local/bin/node /usr/local/bin/firebase serve --debug
[2018-09-11T16:12:25.877Z] CLI Version: 4.2.1
[2018-09-11T16:12:25.877Z] Platform: darwin
[2018-09-11T16:12:25.877Z] Node Version: v6.11.3
[2018-09-11T16:12:25.878Z] Time: Tue Sep 11 2018 11:12:25 GMT-0500 (CDT)
[2018-09-11T16:12:25.878Z] ----------------------------------------------------------------------
[2018-09-11T16:12:25.890Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2018-09-11T16:12:25.890Z] > authorizing via signed-in user
[2018-09-11T16:12:25.893Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/skadaddle-10f24
[2018-09-11T16:12:26.210Z] <<< HTTP RESPONSE 200 server=nginx, date=Tue, 11 Sep 2018 16:12:26 GMT, content-type=application/json; charset=utf-8, content-length=114, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-09-11T16:12:26.212Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/skadaddle-10f24
[2018-09-11T16:12:26.385Z] …Run Code Online (Sandbox Code Playgroud) 我试图在应用程序中进行一些修改后,最初从https://github.com/subhendukundu/template-react-ssr/tree/feature/react-router分发的firebase中部署我的SSR应用程序.我做的时候工作得很好,sudo firebase serve --only functions,hosting但是当我做的时候会抛出错误firebase deploy.可重复的回购是https://github.com/subhendukundu/template-react-ssr/tree/feature/react-router,它有一个package.json https://github.com/subhendukundu/template-react-ssr/ tree/feature/react-router/public
我也使用公共目录作为我的函数目录,https://github.com/subhendukundu/template-react-ssr/blob/feature/react-router/firebase.json.但是,即使我为我的云功能使用不同的功能目录,我也会看到相同的错误.无论如何我能解决它吗?
firebase reactjs firebase-hosting google-cloud-functions next.js
我在 Firebase 中托管我的 Web 应用程序,并使用 Gitlab CI/CD 部署它,并且它一直工作得很好!但今天由于某种原因我在管道工作时收到此错误
\n56Error: Failed to list functions for project-name
这是我在管道中运行的命令
\n firebase deploy --only hosting --non-interactive --token $FIREBASE_TOKEN
这是我收到的错误
\ndeploying hosting\n50i hosting[project-name]: beginning deploy...\n51i hosting[project-name]: found 39 files in dist/dev\n52i hosting: hashing files [34/39] (87%)\n53i hosting: upload complete\n54\xe2\x9c\x94 hosting[project-name]: file upload complete\n55i hosting[project-name]: finalizing version...\n56Error: Failed to list functions for project-name\nRun Code Online (Sandbox Code Playgroud)\n请注意,该命令正在运行,直到显示“最终版本...”,然后停止。
\n什么可能导致此错误?
\n使用部署在 firebase 上的 next.js 应用程序。
我已经部署了该应用程序并使用了一段时间。
我尝试过但不起作用的解决方案:
"rewrites": [
{
"source": "/job/**",
"destination": "/job/[jobId]/index.html"
}
Run Code Online (Sandbox Code Playgroud)
我找到了很多解决这个问题的方法,但没有一个不适合我。
任何想法?
firebase.json 文件:
{
"hosting": {
"public": "out",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"cleanUrls": true,
"rewrites": [
{
"source": "**",
"destination": "out/index.html"
}
]
},
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": ["npm --prefix \"$RESOURCE_DIR\" run build"]
}
]
}
Run Code Online (Sandbox Code Playgroud) 我在 Firebase 上以自定义域名托管我的 Angular 网络应用程序。我通过 Namecheap 购买了域名。
现在我想用我的自定义域接收电子邮件。例如,从 info@atila.ca 发送和接收电子邮件。我已经在 cPanel 中进行了设置,但是当我尝试发送到此电子邮件时,出现以下错误:
<info@atila.ca>: unknown user: "info@atila.ca"
Reporting-MTA: dns; eforward3e.registrar-servers.com
Run Code Online (Sandbox Code Playgroud)
这是 Firebase、Namecheap 或 cpanel 的问题吗?关于如何解决这个问题的任何建议?
firebase-hosting ×10
firebase ×8
next.js ×3
reactjs ×2
angularjs ×1
caching ×1
cicd ×1
deployment ×1
email ×1
firebase-cli ×1
gitlab ×1
javascript ×1
json ×1
serverless ×1